diff options
Diffstat (limited to 'OpenSim/OpenSim.Region')
24 files changed, 0 insertions, 5479 deletions
diff --git a/OpenSim/OpenSim.Region/Caps.cs b/OpenSim/OpenSim.Region/Caps.cs deleted file mode 100644 index 13a351d..0000000 --- a/OpenSim/OpenSim.Region/Caps.cs +++ /dev/null | |||
@@ -1,258 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using System.Text; | ||
5 | using System.IO; | ||
6 | using System.Xml; | ||
7 | using OpenSim.Servers; | ||
8 | using OpenSim.Framework; | ||
9 | using OpenSim.Framework.Utilities; | ||
10 | using OpenSim.Framework.Types; | ||
11 | using OpenSim.Caches; | ||
12 | using libsecondlife; | ||
13 | |||
14 | namespace OpenSim.Region | ||
15 | { | ||
16 | public delegate void UpLoadedTexture(LLUUID assetID, LLUUID inventoryItem, byte[] data); | ||
17 | |||
18 | public class Caps | ||
19 | { | ||
20 | private string httpListenerAddress; | ||
21 | private uint httpListenPort; | ||
22 | private string capsObjectPath = "00001-"; | ||
23 | private string requestPath = "0000/"; | ||
24 | private string mapLayerPath = "0001/"; | ||
25 | private string newInventory = "0002/"; | ||
26 | private string requestTexture = "0003/"; | ||
27 | private string eventQueue = "0100/"; | ||
28 | private BaseHttpServer httpListener; | ||
29 | private LLUUID agentID; | ||
30 | private AssetCache assetCache; | ||
31 | private int eventQueueCount = 1; | ||
32 | private Queue<string> CapsEventQueue = new Queue<string>(); | ||
33 | |||
34 | public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, LLUUID agent) | ||
35 | { | ||
36 | assetCache = assetCach; | ||
37 | capsObjectPath = capsPath; | ||
38 | httpListener = httpServer; | ||
39 | httpListenerAddress = httpListen; | ||
40 | httpListenPort = httpPort; | ||
41 | agentID = agent; | ||
42 | } | ||
43 | |||
44 | /// <summary> | ||
45 | /// | ||
46 | /// </summary> | ||
47 | public void RegisterHandlers() | ||
48 | { | ||
49 | Console.WriteLine("registering CAPS handlers"); | ||
50 | httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + requestPath, CapsRequest); | ||
51 | httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + mapLayerPath, MapLayer); | ||
52 | httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + newInventory, NewAgentInventory); | ||
53 | httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + eventQueue, ProcessEventQueue); | ||
54 | } | ||
55 | |||
56 | /// <summary> | ||
57 | /// | ||
58 | /// </summary> | ||
59 | /// <param name="request"></param> | ||
60 | /// <param name="path"></param> | ||
61 | /// <param name="param"></param> | ||
62 | /// <returns></returns> | ||
63 | public string CapsRequest(string request, string path, string param) | ||
64 | { | ||
65 | // Console.WriteLine("Caps Request " + request); | ||
66 | string result = ""; | ||
67 | result = LLSDHelpers.SerialiseLLSDReply(this.GetCapabilities()); | ||
68 | return result; | ||
69 | } | ||
70 | |||
71 | /// <summary> | ||
72 | /// | ||
73 | /// </summary> | ||
74 | /// <returns></returns> | ||
75 | protected LLSDCapsDetails GetCapabilities() | ||
76 | { | ||
77 | /* string capURLS = ""; | ||
78 | capURLS += "<key>MapLayer</key><string>http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + mapLayerPath + "</string>"; | ||
79 | capURLS += "<key>NewFileAgentInventory</key><string>http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + newInventory + "</string>"; | ||
80 | //capURLS += "<key>RequestTextureDownload</key><string>http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + requestTexture + "</string>"; | ||
81 | //capURLS += "<key>EventQueueGet</key><string>http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + eventQueue + "</string>"; | ||
82 | return capURLS;*/ | ||
83 | |||
84 | LLSDCapsDetails caps = new LLSDCapsDetails(); | ||
85 | caps.MapLayer = "http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + mapLayerPath; | ||
86 | caps.NewFileAgentInventory = "http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + newInventory; | ||
87 | return caps; | ||
88 | } | ||
89 | |||
90 | /// <summary> | ||
91 | /// | ||
92 | /// </summary> | ||
93 | /// <param name="request"></param> | ||
94 | /// <param name="path"></param> | ||
95 | /// <param name="param"></param> | ||
96 | /// <returns></returns> | ||
97 | public string MapLayer(string request, string path, string param) | ||
98 | { | ||
99 | Encoding _enc = System.Text.Encoding.UTF8; | ||
100 | Hashtable hash =(Hashtable) LLSD.LLSDDeserialize(_enc.GetBytes(request)); | ||
101 | LLSDMapRequest mapReq = new LLSDMapRequest(); | ||
102 | LLSDHelpers.DeserialiseLLSDMap(hash, mapReq ); | ||
103 | |||
104 | LLSDMapLayerResponse mapResponse= new LLSDMapLayerResponse(); | ||
105 | mapResponse.LayerData.Array.Add(this.BuildLLSDMapLayerResponse()); | ||
106 | string res = LLSDHelpers.SerialiseLLSDReply(mapResponse); | ||
107 | |||
108 | //Console.WriteLine(" Maplayer response is " + res); | ||
109 | |||
110 | return res; | ||
111 | } | ||
112 | |||
113 | /// <summary> | ||
114 | /// | ||
115 | /// </summary> | ||
116 | /// <returns></returns> | ||
117 | protected LLSDMapLayer BuildLLSDMapLayerResponse() | ||
118 | { | ||
119 | LLSDMapLayer mapLayer = new LLSDMapLayer(); | ||
120 | mapLayer.Right = 5000; | ||
121 | mapLayer.Top = 5000; | ||
122 | mapLayer.ImageID = new LLUUID("00000000-0000-0000-9999-000000000006"); | ||
123 | |||
124 | return mapLayer; | ||
125 | } | ||
126 | |||
127 | public string ProcessEventQueue(string request, string path, string param) | ||
128 | { | ||
129 | // Console.WriteLine("event queue request " + request); | ||
130 | string res = ""; | ||
131 | int timer = 0; | ||
132 | |||
133 | /*while ((timer < 200) || (this.CapsEventQueue.Count < 1)) | ||
134 | { | ||
135 | timer++; | ||
136 | }*/ | ||
137 | if (this.CapsEventQueue.Count > 0) | ||
138 | { | ||
139 | lock (this.CapsEventQueue) | ||
140 | { | ||
141 | string item = CapsEventQueue.Dequeue(); | ||
142 | res = item; | ||
143 | } | ||
144 | } | ||
145 | else | ||
146 | { | ||
147 | res = this.CreateEmptyEventResponse(); | ||
148 | } | ||
149 | return res; | ||
150 | } | ||
151 | |||
152 | public string CreateEstablishAgentComms(string caps, string ipAddressPort) | ||
153 | { | ||
154 | string res = "<llsd><map><key>id</key><integer>" + eventQueueCount + "</integer>"; | ||
155 | res += "<key>events</key><array><map>"; | ||
156 | res += "<key>message</key><string>EstablishAgentCommunication</string>"; | ||
157 | res += "<key>body</key><map>"; | ||
158 | res += "<key>sim-ip-and-port</key><string>" + ipAddressPort + "</string>"; | ||
159 | res += "<key>seed-capability</key><string>" + caps + "</string>"; | ||
160 | res += "<key>agent-id</key><uuid>" + this.agentID.ToStringHyphenated() + "</uuid>"; | ||
161 | res += "</map>"; | ||
162 | res += "</map></array>"; | ||
163 | res += "</map></llsd>"; | ||
164 | eventQueueCount++; | ||
165 | this.CapsEventQueue.Enqueue(res); | ||
166 | return res; | ||
167 | } | ||
168 | |||
169 | public string CreateEmptyEventResponse() | ||
170 | { | ||
171 | string res = "<llsd><map><key>id</key><integer>" + eventQueueCount + "</integer>"; | ||
172 | res += "<key>events</key><array><map>"; | ||
173 | res += "</map></array>"; | ||
174 | res += "</map></llsd>"; | ||
175 | eventQueueCount++; | ||
176 | return res; | ||
177 | } | ||
178 | |||
179 | public string NewAgentInventory(string request, string path, string param) | ||
180 | { | ||
181 | //Console.WriteLine("received upload request:"+ request); | ||
182 | string res = ""; | ||
183 | LLUUID newAsset = LLUUID.Random(); | ||
184 | LLUUID newInvItem = LLUUID.Random(); | ||
185 | string uploaderPath = capsObjectPath + Util.RandomClass.Next(5000, 8000).ToString("0000"); | ||
186 | AssetUploader uploader = new AssetUploader(newAsset, newInvItem, uploaderPath, this.httpListener); | ||
187 | httpListener.AddRestHandler("POST", "/CAPS/" + uploaderPath, uploader.uploaderCaps); | ||
188 | string uploaderURL = "http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + uploaderPath; | ||
189 | //Console.WriteLine("uploader url is " + uploaderURL); | ||
190 | res += "<llsd><map>"; | ||
191 | res += "<key>uploader</key><string>" + uploaderURL + "</string>"; | ||
192 | //res += "<key>success</key><boolean>true</boolean>"; | ||
193 | res += "<key>state</key><string>upload</string>"; | ||
194 | res += "</map></llsd>"; | ||
195 | uploader.OnUpLoad += this.UploadHandler; | ||
196 | return res; | ||
197 | } | ||
198 | |||
199 | public void UploadHandler(LLUUID assetID, LLUUID inventoryItem, byte[] data) | ||
200 | { | ||
201 | // Console.WriteLine("upload handler called"); | ||
202 | AssetBase asset; | ||
203 | asset = new AssetBase(); | ||
204 | asset.FullID = assetID; | ||
205 | asset.Type = 0; | ||
206 | asset.InvType = 0; | ||
207 | asset.Name = "UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000"); | ||
208 | asset.Data = data; | ||
209 | this.assetCache.AddAsset(asset); | ||
210 | } | ||
211 | |||
212 | public class AssetUploader | ||
213 | { | ||
214 | public event UpLoadedTexture OnUpLoad; | ||
215 | |||
216 | private string uploaderPath = ""; | ||
217 | private LLUUID newAssetID; | ||
218 | private LLUUID inventoryItemID; | ||
219 | private BaseHttpServer httpListener; | ||
220 | public AssetUploader(LLUUID assetID, LLUUID inventoryItem, string path, BaseHttpServer httpServer) | ||
221 | { | ||
222 | newAssetID = assetID; | ||
223 | inventoryItemID = inventoryItem; | ||
224 | uploaderPath = path; | ||
225 | httpListener = httpServer; | ||
226 | |||
227 | } | ||
228 | |||
229 | public string uploaderCaps(string request, string path, string param) | ||
230 | { | ||
231 | Encoding _enc = System.Text.Encoding.UTF8; | ||
232 | byte[] data = _enc.GetBytes(request); | ||
233 | //Console.WriteLine("recieved upload " + Util.FieldToString(data)); | ||
234 | LLUUID inv = this.inventoryItemID; | ||
235 | string res = ""; | ||
236 | res += "<llsd><map>"; | ||
237 | res += "<key>new_asset</key><string>" + newAssetID.ToStringHyphenated() + "</string>"; | ||
238 | res += "<key>new_inventory_item</key><uuid>" + inv.ToStringHyphenated() + "</uuid>"; | ||
239 | res += "<key>state</key><string>complete</string>"; | ||
240 | res += "</map></llsd>"; | ||
241 | |||
242 | // Console.WriteLine("asset " + newAssetID.ToStringHyphenated() + " , inventory item " + inv.ToStringHyphenated()); | ||
243 | httpListener.RemoveRestHandler("POST", "/CAPS/" + uploaderPath); | ||
244 | if (OnUpLoad != null) | ||
245 | { | ||
246 | OnUpLoad(newAssetID, inv, data); | ||
247 | } | ||
248 | |||
249 | /*FileStream fs = File.Create("upload.jp2"); | ||
250 | BinaryWriter bw = new BinaryWriter(fs); | ||
251 | bw.Write(data); | ||
252 | bw.Close(); | ||
253 | fs.Close();*/ | ||
254 | return res; | ||
255 | } | ||
256 | } | ||
257 | } | ||
258 | } | ||
diff --git a/OpenSim/OpenSim.Region/EstateManager.cs b/OpenSim/OpenSim.Region/EstateManager.cs deleted file mode 100644 index dcb5564..0000000 --- a/OpenSim/OpenSim.Region/EstateManager.cs +++ /dev/null | |||
@@ -1,301 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.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.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using OpenSim.Framework.Types; | ||
32 | using OpenSim.Framework.Interfaces; | ||
33 | using OpenSim.Region; | ||
34 | using OpenSim.Region.Scenes; | ||
35 | using OpenSim; | ||
36 | using libsecondlife; | ||
37 | using libsecondlife.Packets; | ||
38 | using Avatar = OpenSim.Region.Scenes.ScenePresence; | ||
39 | |||
40 | |||
41 | namespace OpenSim.Region | ||
42 | { | ||
43 | |||
44 | /// <summary> | ||
45 | /// Processes requests regarding estates. Refer to EstateSettings.cs in OpenSim.Framework. Types for all of the core settings | ||
46 | /// </summary> | ||
47 | public class EstateManager | ||
48 | { | ||
49 | private Scene m_world; | ||
50 | private RegionInfo m_regInfo; | ||
51 | |||
52 | public EstateManager(Scene world,RegionInfo reginfo) | ||
53 | { | ||
54 | m_world = world; //Estate settings found at world.m_regInfo.estateSettings | ||
55 | m_regInfo = reginfo; | ||
56 | } | ||
57 | |||
58 | private bool convertParamStringToBool(byte[] field) | ||
59 | { | ||
60 | string s = Helpers.FieldToUTF8String(field); | ||
61 | if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true") | ||
62 | { | ||
63 | return true; | ||
64 | } | ||
65 | return false; | ||
66 | } | ||
67 | |||
68 | public void handleEstateOwnerMessage(EstateOwnerMessagePacket packet, IClientAPI remote_client) | ||
69 | { | ||
70 | if (remote_client.AgentId == m_regInfo.MasterAvatarAssignedUUID) | ||
71 | { | ||
72 | switch (Helpers.FieldToUTF8String(packet.MethodData.Method)) | ||
73 | { | ||
74 | case "getinfo": | ||
75 | Console.WriteLine("GETINFO Requested"); | ||
76 | this.sendRegionInfoPacketToAll(); | ||
77 | |||
78 | break; | ||
79 | case "setregioninfo": | ||
80 | if (packet.ParamList.Length != 9) | ||
81 | { | ||
82 | OpenSim.Framework.Console.MainLog.Instance.Error("EstateOwnerMessage: SetRegionInfo method has a ParamList of invalid length"); | ||
83 | } | ||
84 | else | ||
85 | { | ||
86 | m_regInfo.estateSettings.regionFlags = libsecondlife.Simulator.RegionFlags.None; | ||
87 | |||
88 | if (convertParamStringToBool(packet.ParamList[0].Parameter)) | ||
89 | { | ||
90 | m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | libsecondlife.Simulator.RegionFlags.BlockTerraform; | ||
91 | } | ||
92 | |||
93 | if (convertParamStringToBool(packet.ParamList[1].Parameter)) | ||
94 | { | ||
95 | m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | libsecondlife.Simulator.RegionFlags.NoFly; | ||
96 | } | ||
97 | |||
98 | if (convertParamStringToBool(packet.ParamList[2].Parameter)) | ||
99 | { | ||
100 | m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | libsecondlife.Simulator.RegionFlags.AllowDamage; | ||
101 | } | ||
102 | |||
103 | if (convertParamStringToBool(packet.ParamList[3].Parameter) == false) | ||
104 | { | ||
105 | m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | libsecondlife.Simulator.RegionFlags.BlockLandResell; | ||
106 | } | ||
107 | |||
108 | |||
109 | int tempMaxAgents = Convert.ToInt16(Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[4].Parameter))); | ||
110 | m_regInfo.estateSettings.maxAgents = (byte)tempMaxAgents; | ||
111 | |||
112 | float tempObjectBonusFactor = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter)); | ||
113 | m_regInfo.estateSettings.objectBonusFactor = tempObjectBonusFactor; | ||
114 | |||
115 | int tempMatureLevel = Convert.ToInt16(Helpers.FieldToUTF8String(packet.ParamList[6].Parameter)); | ||
116 | m_regInfo.estateSettings.simAccess = (libsecondlife.Simulator.SimAccess)tempMatureLevel; | ||
117 | |||
118 | |||
119 | if (convertParamStringToBool(packet.ParamList[7].Parameter)) | ||
120 | { | ||
121 | m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | libsecondlife.Simulator.RegionFlags.RestrictPushObject; | ||
122 | } | ||
123 | |||
124 | if (convertParamStringToBool(packet.ParamList[8].Parameter)) | ||
125 | { | ||
126 | m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | libsecondlife.Simulator.RegionFlags.AllowParcelChanges; | ||
127 | } | ||
128 | |||
129 | sendRegionInfoPacketToAll(); | ||
130 | |||
131 | } | ||
132 | break; | ||
133 | case "texturebase": | ||
134 | foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList) | ||
135 | { | ||
136 | string s = Helpers.FieldToUTF8String(block.Parameter); | ||
137 | string[] splitField = s.Split(' '); | ||
138 | if (splitField.Length == 2) | ||
139 | { | ||
140 | LLUUID tempUUID = new LLUUID(splitField[1]); | ||
141 | switch (Convert.ToInt16(splitField[0])) | ||
142 | { | ||
143 | case 0: | ||
144 | m_regInfo.estateSettings.terrainBase0 = tempUUID; | ||
145 | break; | ||
146 | case 1: | ||
147 | m_regInfo.estateSettings.terrainBase1 = tempUUID; | ||
148 | break; | ||
149 | case 2: | ||
150 | m_regInfo.estateSettings.terrainBase2 = tempUUID; | ||
151 | break; | ||
152 | case 3: | ||
153 | m_regInfo.estateSettings.terrainBase3 = tempUUID; | ||
154 | break; | ||
155 | } | ||
156 | } | ||
157 | } | ||
158 | break; | ||
159 | case "texturedetail": | ||
160 | foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList) | ||
161 | { | ||
162 | |||
163 | string s = Helpers.FieldToUTF8String(block.Parameter); | ||
164 | string[] splitField = s.Split(' '); | ||
165 | if (splitField.Length == 2) | ||
166 | { | ||
167 | LLUUID tempUUID = new LLUUID(splitField[1]); | ||
168 | switch (Convert.ToInt16(splitField[0])) | ||
169 | { | ||
170 | case 0: | ||
171 | m_regInfo.estateSettings.terrainDetail0 = tempUUID; | ||
172 | break; | ||
173 | case 1: | ||
174 | m_regInfo.estateSettings.terrainDetail1 = tempUUID; | ||
175 | break; | ||
176 | case 2: | ||
177 | m_regInfo.estateSettings.terrainDetail2 = tempUUID; | ||
178 | break; | ||
179 | case 3: | ||
180 | m_regInfo.estateSettings.terrainDetail3 = tempUUID; | ||
181 | break; | ||
182 | } | ||
183 | } | ||
184 | } | ||
185 | break; | ||
186 | case "textureheights": | ||
187 | foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList) | ||
188 | { | ||
189 | |||
190 | string s = Helpers.FieldToUTF8String(block.Parameter); | ||
191 | string[] splitField = s.Split(' '); | ||
192 | if (splitField.Length == 3) | ||
193 | { | ||
194 | |||
195 | float tempHeightLow = (float)Convert.ToDecimal(splitField[1]); | ||
196 | float tempHeightHigh = (float)Convert.ToDecimal(splitField[2]); | ||
197 | |||
198 | switch (Convert.ToInt16(splitField[0])) | ||
199 | { | ||
200 | case 0: | ||
201 | m_regInfo.estateSettings.terrainStartHeight0 = tempHeightLow; | ||
202 | m_regInfo.estateSettings.terrainHeightRange0 = tempHeightHigh; | ||
203 | break; | ||
204 | case 1: | ||
205 | m_regInfo.estateSettings.terrainStartHeight1 = tempHeightLow; | ||
206 | m_regInfo.estateSettings.terrainHeightRange1 = tempHeightHigh; | ||
207 | break; | ||
208 | case 2: | ||
209 | m_regInfo.estateSettings.terrainStartHeight2 = tempHeightLow; | ||
210 | m_regInfo.estateSettings.terrainHeightRange2 = tempHeightHigh; | ||
211 | break; | ||
212 | case 3: | ||
213 | m_regInfo.estateSettings.terrainStartHeight3 = tempHeightLow; | ||
214 | m_regInfo.estateSettings.terrainHeightRange3 = tempHeightHigh; | ||
215 | break; | ||
216 | } | ||
217 | } | ||
218 | } | ||
219 | break; | ||
220 | case "texturecommit": | ||
221 | sendRegionHandshakeToAll(); | ||
222 | break; | ||
223 | case "setregionterrain": | ||
224 | if (packet.ParamList.Length != 9) | ||
225 | { | ||
226 | OpenSim.Framework.Console.MainLog.Instance.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length"); | ||
227 | } | ||
228 | else | ||
229 | { | ||
230 | m_regInfo.estateSettings.waterHeight = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[0].Parameter)); | ||
231 | m_regInfo.estateSettings.terrainRaiseLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter)); | ||
232 | m_regInfo.estateSettings.terrainLowerLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter)); | ||
233 | m_regInfo.estateSettings.useFixedSun = this.convertParamStringToBool(packet.ParamList[4].Parameter); | ||
234 | m_regInfo.estateSettings.sunHour = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter)); | ||
235 | |||
236 | sendRegionInfoPacketToAll(); | ||
237 | } | ||
238 | break; | ||
239 | default: | ||
240 | OpenSim.Framework.Console.MainLog.Instance.Error("EstateOwnerMessage: Unknown method requested\n" + packet.ToString()); | ||
241 | break; | ||
242 | } | ||
243 | } | ||
244 | } | ||
245 | |||
246 | public void sendRegionInfoPacketToAll() | ||
247 | { | ||
248 | List<Avatar> avatars = m_world.RequestAvatarList(); | ||
249 | |||
250 | for (int i = 0; i < avatars.Count; i++) | ||
251 | { | ||
252 | this.sendRegionInfoPacket(avatars[i].ControllingClient); | ||
253 | } | ||
254 | } | ||
255 | |||
256 | public void sendRegionHandshakeToAll() | ||
257 | { | ||
258 | List<Avatar> avatars = m_world.RequestAvatarList(); | ||
259 | |||
260 | for (int i = 0; i < avatars.Count; i++) | ||
261 | { | ||
262 | this.sendRegionHandshake(avatars[i].ControllingClient); | ||
263 | } | ||
264 | } | ||
265 | |||
266 | public void sendRegionInfoPacket(IClientAPI remote_client) | ||
267 | { | ||
268 | Encoding _enc = System.Text.Encoding.ASCII; | ||
269 | |||
270 | AgentCircuitData circuitData = remote_client.RequestClientInfo(); | ||
271 | |||
272 | RegionInfoPacket regionInfoPacket = new RegionInfoPacket(); | ||
273 | regionInfoPacket.AgentData.AgentID = circuitData.AgentID; | ||
274 | regionInfoPacket.AgentData.SessionID = circuitData.SessionID; | ||
275 | regionInfoPacket.RegionInfo.BillableFactor = m_regInfo.estateSettings.billableFactor; | ||
276 | regionInfoPacket.RegionInfo.EstateID = m_regInfo.estateSettings.estateID; | ||
277 | regionInfoPacket.RegionInfo.MaxAgents = m_regInfo.estateSettings.maxAgents; | ||
278 | regionInfoPacket.RegionInfo.ObjectBonusFactor = m_regInfo.estateSettings.objectBonusFactor; | ||
279 | regionInfoPacket.RegionInfo.ParentEstateID = m_regInfo.estateSettings.parentEstateID; | ||
280 | regionInfoPacket.RegionInfo.PricePerMeter = m_regInfo.estateSettings.pricePerMeter; | ||
281 | regionInfoPacket.RegionInfo.RedirectGridX = m_regInfo.estateSettings.redirectGridX; | ||
282 | regionInfoPacket.RegionInfo.RedirectGridY = m_regInfo.estateSettings.redirectGridY; | ||
283 | regionInfoPacket.RegionInfo.RegionFlags = (uint)m_regInfo.estateSettings.regionFlags; | ||
284 | regionInfoPacket.RegionInfo.SimAccess = (byte)m_regInfo.estateSettings.simAccess; | ||
285 | regionInfoPacket.RegionInfo.SimName = _enc.GetBytes( m_regInfo.RegionName); | ||
286 | regionInfoPacket.RegionInfo.SunHour = m_regInfo.estateSettings.sunHour; | ||
287 | regionInfoPacket.RegionInfo.TerrainLowerLimit = m_regInfo.estateSettings.terrainLowerLimit; | ||
288 | regionInfoPacket.RegionInfo.TerrainRaiseLimit = m_regInfo.estateSettings.terrainRaiseLimit; | ||
289 | regionInfoPacket.RegionInfo.UseEstateSun = !m_regInfo.estateSettings.useFixedSun; | ||
290 | regionInfoPacket.RegionInfo.WaterHeight = m_regInfo.estateSettings.waterHeight; | ||
291 | |||
292 | remote_client.OutPacket(regionInfoPacket); | ||
293 | } | ||
294 | |||
295 | public void sendRegionHandshake(IClientAPI remoteClient) | ||
296 | { | ||
297 | remoteClient.SendRegionHandshake(m_regInfo); | ||
298 | } | ||
299 | |||
300 | } | ||
301 | } | ||
diff --git a/OpenSim/OpenSim.Region/OpenSim.Region.csproj b/OpenSim/OpenSim.Region/OpenSim.Region.csproj deleted file mode 100644 index 79f204d..0000000 --- a/OpenSim/OpenSim.Region/OpenSim.Region.csproj +++ /dev/null | |||
@@ -1,221 +0,0 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <ProjectType>Local</ProjectType> | ||
4 | <ProductVersion>8.0.50727</ProductVersion> | ||
5 | <SchemaVersion>2.0</SchemaVersion> | ||
6 | <ProjectGuid>{196916AF-0000-0000-0000-000000000000}</ProjectGuid> | ||
7 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
8 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
9 | <ApplicationIcon></ApplicationIcon> | ||
10 | <AssemblyKeyContainerName> | ||
11 | </AssemblyKeyContainerName> | ||
12 | <AssemblyName>OpenSim.Region</AssemblyName> | ||
13 | <DefaultClientScript>JScript</DefaultClientScript> | ||
14 | <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout> | ||
15 | <DefaultTargetSchema>IE50</DefaultTargetSchema> | ||
16 | <DelaySign>false</DelaySign> | ||
17 | <OutputType>Library</OutputType> | ||
18 | <AppDesignerFolder></AppDesignerFolder> | ||
19 | <RootNamespace>OpenSim.Region</RootNamespace> | ||
20 | <StartupObject></StartupObject> | ||
21 | <FileUpgradeFlags> | ||
22 | </FileUpgradeFlags> | ||
23 | </PropertyGroup> | ||
24 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
25 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
26 | <BaseAddress>285212672</BaseAddress> | ||
27 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
28 | <ConfigurationOverrideFile> | ||
29 | </ConfigurationOverrideFile> | ||
30 | <DefineConstants>TRACE;DEBUG</DefineConstants> | ||
31 | <DocumentationFile></DocumentationFile> | ||
32 | <DebugSymbols>True</DebugSymbols> | ||
33 | <FileAlignment>4096</FileAlignment> | ||
34 | <Optimize>False</Optimize> | ||
35 | <OutputPath>..\..\bin\</OutputPath> | ||
36 | <RegisterForComInterop>False</RegisterForComInterop> | ||
37 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
38 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
39 | <WarningLevel>4</WarningLevel> | ||
40 | <NoWarn></NoWarn> | ||
41 | </PropertyGroup> | ||
42 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
43 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
44 | <BaseAddress>285212672</BaseAddress> | ||
45 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
46 | <ConfigurationOverrideFile> | ||
47 | </ConfigurationOverrideFile> | ||
48 | <DefineConstants>TRACE</DefineConstants> | ||
49 | <DocumentationFile></DocumentationFile> | ||
50 | <DebugSymbols>False</DebugSymbols> | ||
51 | <FileAlignment>4096</FileAlignment> | ||
52 | <Optimize>True</Optimize> | ||
53 | <OutputPath>..\..\bin\</OutputPath> | ||
54 | <RegisterForComInterop>False</RegisterForComInterop> | ||
55 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
56 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
57 | <WarningLevel>4</WarningLevel> | ||
58 | <NoWarn></NoWarn> | ||
59 | </PropertyGroup> | ||
60 | <ItemGroup> | ||
61 | <Reference Include="Axiom.MathLib.dll" > | ||
62 | <HintPath>..\..\bin\Axiom.MathLib.dll</HintPath> | ||
63 | <Private>False</Private> | ||
64 | </Reference> | ||
65 | <Reference Include="Db4objects.Db4o.dll" > | ||
66 | <HintPath>..\..\bin\Db4objects.Db4o.dll</HintPath> | ||
67 | <Private>False</Private> | ||
68 | </Reference> | ||
69 | <Reference Include="libsecondlife.dll" > | ||
70 | <HintPath>..\..\bin\libsecondlife.dll</HintPath> | ||
71 | <Private>False</Private> | ||
72 | </Reference> | ||
73 | <Reference Include="Microsoft.JScript" > | ||
74 | <HintPath>Microsoft.JScript.dll</HintPath> | ||
75 | <Private>False</Private> | ||
76 | </Reference> | ||
77 | <Reference Include="System" > | ||
78 | <HintPath>System.dll</HintPath> | ||
79 | <Private>False</Private> | ||
80 | </Reference> | ||
81 | <Reference Include="System.Xml" > | ||
82 | <HintPath>System.Xml.dll</HintPath> | ||
83 | <Private>False</Private> | ||
84 | </Reference> | ||
85 | <Reference Include="VJSharpCodeProvider" > | ||
86 | <HintPath>VJSharpCodeProvider.dll</HintPath> | ||
87 | <Private>False</Private> | ||
88 | </Reference> | ||
89 | </ItemGroup> | ||
90 | <ItemGroup> | ||
91 | <ProjectReference Include="..\..\Common\OpenGrid.Framework.Communications\OpenGrid.Framework.Communications.csproj"> | ||
92 | <Name>OpenGrid.Framework.Communications</Name> | ||
93 | <Project>{683344D5-0000-0000-0000-000000000000}</Project> | ||
94 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
95 | <Private>False</Private> | ||
96 | </ProjectReference> | ||
97 | <ProjectReference Include="..\OpenSim.Caches\OpenSim.Caches.csproj"> | ||
98 | <Name>OpenSim.Caches</Name> | ||
99 | <Project>{1938EB12-0000-0000-0000-000000000000}</Project> | ||
100 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
101 | <Private>False</Private> | ||
102 | </ProjectReference> | ||
103 | <ProjectReference Include="..\..\Common\OpenSim.Framework\OpenSim.Framework.csproj"> | ||
104 | <Name>OpenSim.Framework</Name> | ||
105 | <Project>{8ACA2445-0000-0000-0000-000000000000}</Project> | ||
106 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
107 | <Private>False</Private> | ||
108 | </ProjectReference> | ||
109 | <ProjectReference Include="..\..\Common\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj"> | ||
110 | <Name>OpenSim.Framework.Console</Name> | ||
111 | <Project>{A7CD0630-0000-0000-0000-000000000000}</Project> | ||
112 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
113 | <Private>False</Private> | ||
114 | </ProjectReference> | ||
115 | <ProjectReference Include="..\..\Common\OpenSim.GenericConfig\Xml\OpenSim.GenericConfig.Xml.csproj"> | ||
116 | <Name>OpenSim.GenericConfig.Xml</Name> | ||
117 | <Project>{E88EF749-0000-0000-0000-000000000000}</Project> | ||
118 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
119 | <Private>False</Private> | ||
120 | </ProjectReference> | ||
121 | <ProjectReference Include="..\OpenSim.Physics\Manager\OpenSim.Physics.Manager.csproj"> | ||
122 | <Name>OpenSim.Physics.Manager</Name> | ||
123 | <Project>{8BE16150-0000-0000-0000-000000000000}</Project> | ||
124 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
125 | <Private>False</Private> | ||
126 | </ProjectReference> | ||
127 | <ProjectReference Include="..\..\Common\OpenSim.Servers\OpenSim.Servers.csproj"> | ||
128 | <Name>OpenSim.Servers</Name> | ||
129 | <Project>{8BB20F0A-0000-0000-0000-000000000000}</Project> | ||
130 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
131 | <Private>False</Private> | ||
132 | </ProjectReference> | ||
133 | <ProjectReference Include="..\OpenSim.Terrain.BasicTerrain\OpenSim.Terrain.BasicTerrain.csproj"> | ||
134 | <Name>OpenSim.Terrain.BasicTerrain</Name> | ||
135 | <Project>{2270B8FE-0000-0000-0000-000000000000}</Project> | ||
136 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
137 | <Private>False</Private> | ||
138 | </ProjectReference> | ||
139 | <ProjectReference Include="..\..\Common\XmlRpcCS\XMLRPC.csproj"> | ||
140 | <Name>XMLRPC</Name> | ||
141 | <Project>{8E81D43C-0000-0000-0000-000000000000}</Project> | ||
142 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
143 | <Private>False</Private> | ||
144 | </ProjectReference> | ||
145 | </ItemGroup> | ||
146 | <ItemGroup> | ||
147 | <Compile Include="Caps.cs"> | ||
148 | <SubType>Code</SubType> | ||
149 | </Compile> | ||
150 | <Compile Include="EstateManager.cs"> | ||
151 | <SubType>Code</SubType> | ||
152 | </Compile> | ||
153 | <Compile Include="ParcelManager.cs"> | ||
154 | <SubType>Code</SubType> | ||
155 | </Compile> | ||
156 | <Compile Include="RegionManager.cs"> | ||
157 | <SubType>Code</SubType> | ||
158 | </Compile> | ||
159 | <Compile Include="Scenes\Entity.cs"> | ||
160 | <SubType>Code</SubType> | ||
161 | </Compile> | ||
162 | <Compile Include="Scenes\IScenePresenceBody.cs"> | ||
163 | <SubType>Code</SubType> | ||
164 | </Compile> | ||
165 | <Compile Include="Scenes\Primitive.cs"> | ||
166 | <SubType>Code</SubType> | ||
167 | </Compile> | ||
168 | <Compile Include="Scenes\Scene.cs"> | ||
169 | <SubType>Code</SubType> | ||
170 | </Compile> | ||
171 | <Compile Include="Scenes\Scene.PacketHandlers.cs"> | ||
172 | <SubType>Code</SubType> | ||
173 | </Compile> | ||
174 | <Compile Include="Scenes\Scene.Scripting.cs"> | ||
175 | <SubType>Code</SubType> | ||
176 | </Compile> | ||
177 | <Compile Include="Scenes\SceneBase.cs"> | ||
178 | <SubType>Code</SubType> | ||
179 | </Compile> | ||
180 | <Compile Include="Scenes\SceneEvents.cs"> | ||
181 | <SubType>Code</SubType> | ||
182 | </Compile> | ||
183 | <Compile Include="Scenes\SceneObject.cs"> | ||
184 | <SubType>Code</SubType> | ||
185 | </Compile> | ||
186 | <Compile Include="Scenes\ScenePresence.Animations.cs"> | ||
187 | <SubType>Code</SubType> | ||
188 | </Compile> | ||
189 | <Compile Include="Scenes\ScenePresence.Body.cs"> | ||
190 | <SubType>Code</SubType> | ||
191 | </Compile> | ||
192 | <Compile Include="Scenes\ScenePresence.cs"> | ||
193 | <SubType>Code</SubType> | ||
194 | </Compile> | ||
195 | <Compile Include="Scenes\scripting\Script.cs"> | ||
196 | <SubType>Code</SubType> | ||
197 | </Compile> | ||
198 | <Compile Include="Scenes\scripting\ScriptInfo.cs"> | ||
199 | <SubType>Code</SubType> | ||
200 | </Compile> | ||
201 | <Compile Include="Scenes\scripting\ScriptManager.cs"> | ||
202 | <SubType>Code</SubType> | ||
203 | </Compile> | ||
204 | <Compile Include="Scenes\scripting\Engines\CSharpScriptEngine.cs"> | ||
205 | <SubType>Code</SubType> | ||
206 | </Compile> | ||
207 | <Compile Include="Scenes\scripting\Engines\JScriptEngine.cs"> | ||
208 | <SubType>Code</SubType> | ||
209 | </Compile> | ||
210 | <Compile Include="Scenes\scripting\Engines\JSharpScriptEngine.cs"> | ||
211 | <SubType>Code</SubType> | ||
212 | </Compile> | ||
213 | </ItemGroup> | ||
214 | <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> | ||
215 | <PropertyGroup> | ||
216 | <PreBuildEvent> | ||
217 | </PreBuildEvent> | ||
218 | <PostBuildEvent> | ||
219 | </PostBuildEvent> | ||
220 | </PropertyGroup> | ||
221 | </Project> | ||
diff --git a/OpenSim/OpenSim.Region/OpenSim.Region.dll.build b/OpenSim/OpenSim.Region/OpenSim.Region.dll.build deleted file mode 100644 index 926b9ed..0000000 --- a/OpenSim/OpenSim.Region/OpenSim.Region.dll.build +++ /dev/null | |||
@@ -1,75 +0,0 @@ | |||
1 | <?xml version="1.0" ?> | ||
2 | <project name="OpenSim.Region" default="build"> | ||
3 | <target name="build"> | ||
4 | <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" /> | ||
5 | <mkdir dir="${project::get-base-directory()}/${build.dir}" /> | ||
6 | <copy todir="${project::get-base-directory()}/${build.dir}"> | ||
7 | <fileset basedir="${project::get-base-directory()}"> | ||
8 | </fileset> | ||
9 | </copy> | ||
10 | <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll"> | ||
11 | <resources prefix="OpenSim.Region" dynamicprefix="true" > | ||
12 | </resources> | ||
13 | <sources failonempty="true"> | ||
14 | <include name="Caps.cs" /> | ||
15 | <include name="EstateManager.cs" /> | ||
16 | <include name="ParcelManager.cs" /> | ||
17 | <include name="RegionManager.cs" /> | ||
18 | <include name="Scenes/Entity.cs" /> | ||
19 | <include name="Scenes/IScenePresenceBody.cs" /> | ||
20 | <include name="Scenes/Primitive.cs" /> | ||
21 | <include name="Scenes/Scene.cs" /> | ||
22 | <include name="Scenes/Scene.PacketHandlers.cs" /> | ||
23 | <include name="Scenes/Scene.Scripting.cs" /> | ||
24 | <include name="Scenes/SceneBase.cs" /> | ||
25 | <include name="Scenes/SceneEvents.cs" /> | ||
26 | <include name="Scenes/SceneObject.cs" /> | ||
27 | <include name="Scenes/ScenePresence.Animations.cs" /> | ||
28 | <include name="Scenes/ScenePresence.Body.cs" /> | ||
29 | <include name="Scenes/ScenePresence.cs" /> | ||
30 | <include name="Scenes/scripting/Script.cs" /> | ||
31 | <include name="Scenes/scripting/ScriptInfo.cs" /> | ||
32 | <include name="Scenes/scripting/ScriptManager.cs" /> | ||
33 | <include name="Scenes/scripting/Engines/CSharpScriptEngine.cs" /> | ||
34 | <include name="Scenes/scripting/Engines/JScriptEngine.cs" /> | ||
35 | <include name="Scenes/scripting/Engines/JSharpScriptEngine.cs" /> | ||
36 | </sources> | ||
37 | <references basedir="${project::get-base-directory()}"> | ||
38 | <lib> | ||
39 | <include name="${project::get-base-directory()}" /> | ||
40 | <include name="${project::get-base-directory()}/${build.dir}" /> | ||
41 | </lib> | ||
42 | <include name="../../bin/Axiom.MathLib.dll" /> | ||
43 | <include name="../../bin/Db4objects.Db4o.dll" /> | ||
44 | <include name="../../bin/libsecondlife.dll" /> | ||
45 | <include name="Microsoft.JScript.dll" /> | ||
46 | <include name="../../bin/OpenGrid.Framework.Communications.dll" /> | ||
47 | <include name="../../bin/OpenSim.Caches.dll" /> | ||
48 | <include name="../../bin/OpenSim.Framework.dll" /> | ||
49 | <include name="../../bin/OpenSim.Framework.Console.dll" /> | ||
50 | <include name="../../bin/OpenSim.GenericConfig.Xml.dll" /> | ||
51 | <include name="../../bin/OpenSim.Physics.Manager.dll" /> | ||
52 | <include name="../../bin/OpenSim.Servers.dll" /> | ||
53 | <include name="../../bin/OpenSim.Terrain.BasicTerrain.dll" /> | ||
54 | <include name="System.dll" /> | ||
55 | <include name="System.Xml.dll" /> | ||
56 | <include name="VJSharpCodeProvider.dll" /> | ||
57 | <include name="../../bin/XMLRPC.dll" /> | ||
58 | </references> | ||
59 | </csc> | ||
60 | <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" /> | ||
61 | <mkdir dir="${project::get-base-directory()}/../../bin/"/> | ||
62 | <copy todir="${project::get-base-directory()}/../../bin/"> | ||
63 | <fileset basedir="${project::get-base-directory()}/${build.dir}/" > | ||
64 | <include name="*.dll"/> | ||
65 | <include name="*.exe"/> | ||
66 | </fileset> | ||
67 | </copy> | ||
68 | </target> | ||
69 | <target name="clean"> | ||
70 | <delete dir="${bin.dir}" failonerror="false" /> | ||
71 | <delete dir="${obj.dir}" failonerror="false" /> | ||
72 | </target> | ||
73 | <target name="doc" description="Creates documentation."> | ||
74 | </target> | ||
75 | </project> | ||
diff --git a/OpenSim/OpenSim.Region/ParcelManager.cs b/OpenSim/OpenSim.Region/ParcelManager.cs deleted file mode 100644 index d15d77d..0000000 --- a/OpenSim/OpenSim.Region/ParcelManager.cs +++ /dev/null | |||
@@ -1,892 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.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.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using libsecondlife; | ||
32 | using libsecondlife.Packets; | ||
33 | using OpenSim.Framework.Interfaces; | ||
34 | using OpenSim.Framework.Types; | ||
35 | using OpenSim.Region.Scenes; | ||
36 | using Avatar = OpenSim.Region.Scenes.ScenePresence; | ||
37 | |||
38 | namespace OpenSim.Region | ||
39 | { | ||
40 | |||
41 | |||
42 | #region ParcelManager Class | ||
43 | /// <summary> | ||
44 | /// Handles Parcel objects and operations requiring information from other Parcel objects (divide, join, etc) | ||
45 | /// </summary> | ||
46 | public class ParcelManager : OpenSim.Framework.Interfaces.ILocalStorageParcelReceiver | ||
47 | { | ||
48 | |||
49 | #region Constants | ||
50 | //Parcel types set with flags in ParcelOverlay. | ||
51 | //Only one of these can be used. | ||
52 | public const byte PARCEL_TYPE_PUBLIC = (byte)0; //Equals 00000000 | ||
53 | public const byte PARCEL_TYPE_OWNED_BY_OTHER = (byte)1; //Equals 00000001 | ||
54 | public const byte PARCEL_TYPE_OWNED_BY_GROUP = (byte)2; //Equals 00000010 | ||
55 | public const byte PARCEL_TYPE_OWNED_BY_REQUESTER = (byte)3; //Equals 00000011 | ||
56 | public const byte PARCEL_TYPE_IS_FOR_SALE = (byte)4; //Equals 00000100 | ||
57 | public const byte PARCEL_TYPE_IS_BEING_AUCTIONED = (byte)5; //Equals 00000101 | ||
58 | |||
59 | |||
60 | //Flags that when set, a border on the given side will be placed | ||
61 | //NOTE: North and East is assumable by the west and south sides (if parcel to east has a west border, then I have an east border; etc) | ||
62 | //This took forever to figure out -- jeesh. /blame LL for even having to send these | ||
63 | public const byte PARCEL_FLAG_PROPERTY_BORDER_WEST = (byte)64; //Equals 01000000 | ||
64 | public const byte PARCEL_FLAG_PROPERTY_BORDER_SOUTH = (byte)128; //Equals 10000000 | ||
65 | |||
66 | //RequestResults (I think these are right, they seem to work): | ||
67 | public const int PARCEL_RESULT_ONE_PARCEL = 0; // The request they made contained only one parcel | ||
68 | public const int PARCEL_RESULT_MULTIPLE_PARCELS = 1; // The request they made contained more than one parcel | ||
69 | |||
70 | //These are other constants. Yay! | ||
71 | public const int START_PARCEL_LOCAL_ID = 1; | ||
72 | #endregion | ||
73 | |||
74 | #region Member Variables | ||
75 | public Dictionary<int, Parcel> parcelList = new Dictionary<int, Parcel>(); | ||
76 | private int lastParcelLocalID = START_PARCEL_LOCAL_ID - 1; | ||
77 | private int[,] parcelIDList = new int[64, 64]; | ||
78 | |||
79 | private Scene m_world; | ||
80 | private RegionInfo m_regInfo; | ||
81 | |||
82 | #endregion | ||
83 | |||
84 | #region Constructors | ||
85 | public ParcelManager(Scene world, RegionInfo reginfo) | ||
86 | { | ||
87 | |||
88 | m_world = world; | ||
89 | m_regInfo = reginfo; | ||
90 | parcelIDList.Initialize(); | ||
91 | |||
92 | } | ||
93 | #endregion | ||
94 | |||
95 | #region Member Functions | ||
96 | |||
97 | #region Parcel From Storage Functions | ||
98 | public void ParcelFromStorage(ParcelData data) | ||
99 | { | ||
100 | Parcel new_parcel = new Parcel(data.ownerID, data.isGroupOwned, m_world); | ||
101 | new_parcel.parcelData = data.Copy(); | ||
102 | new_parcel.setParcelBitmapFromByteArray(); | ||
103 | addParcel(new_parcel); | ||
104 | |||
105 | } | ||
106 | |||
107 | public void NoParcelDataFromStorage() | ||
108 | { | ||
109 | resetSimParcels(); | ||
110 | } | ||
111 | #endregion | ||
112 | |||
113 | #region Parcel Add/Remove/Get/Create | ||
114 | /// <summary> | ||
115 | /// Creates a basic Parcel object without an owner (a zeroed key) | ||
116 | /// </summary> | ||
117 | /// <returns></returns> | ||
118 | public Parcel createBaseParcel() | ||
119 | { | ||
120 | return new Parcel(new LLUUID(), false, m_world); | ||
121 | } | ||
122 | |||
123 | /// <summary> | ||
124 | /// Adds a parcel to the stored list and adds them to the parcelIDList to what they own | ||
125 | /// </summary> | ||
126 | /// <param name="new_parcel">The parcel being added</param> | ||
127 | public void addParcel(Parcel new_parcel) | ||
128 | { | ||
129 | lastParcelLocalID++; | ||
130 | new_parcel.parcelData.localID = lastParcelLocalID; | ||
131 | parcelList.Add(lastParcelLocalID, new_parcel.Copy()); | ||
132 | |||
133 | |||
134 | bool[,] parcelBitmap = new_parcel.getParcelBitmap(); | ||
135 | int x, y; | ||
136 | for (x = 0; x < 64; x++) | ||
137 | { | ||
138 | for (y = 0; y < 64; y++) | ||
139 | { | ||
140 | if (parcelBitmap[x, y]) | ||
141 | { | ||
142 | parcelIDList[x, y] = lastParcelLocalID; | ||
143 | } | ||
144 | } | ||
145 | } | ||
146 | parcelList[lastParcelLocalID].forceUpdateParcelInfo(); | ||
147 | |||
148 | |||
149 | } | ||
150 | /// <summary> | ||
151 | /// Removes a parcel from the list. Will not remove if local_id is still owning an area in parcelIDList | ||
152 | /// </summary> | ||
153 | /// <param name="local_id">Parcel.localID of the parcel to remove.</param> | ||
154 | public void removeParcel(int local_id) | ||
155 | { | ||
156 | int x, y; | ||
157 | for (x = 0; x < 64; x++) | ||
158 | { | ||
159 | for (y = 0; y < 64; y++) | ||
160 | { | ||
161 | if (parcelIDList[x, y] == local_id) | ||
162 | { | ||
163 | throw new Exception("Could not remove parcel. Still being used at " + x + ", " + y); | ||
164 | } | ||
165 | } | ||
166 | } | ||
167 | m_world.localStorage.RemoveParcel(parcelList[local_id].parcelData); | ||
168 | parcelList.Remove(local_id); | ||
169 | } | ||
170 | |||
171 | private void performFinalParcelJoin(Parcel master, Parcel slave) | ||
172 | { | ||
173 | int x, y; | ||
174 | bool[,] parcelBitmapSlave = slave.getParcelBitmap(); | ||
175 | for (x = 0; x < 64; x++) | ||
176 | { | ||
177 | for (y = 0; y < 64; y++) | ||
178 | { | ||
179 | if (parcelBitmapSlave[x, y]) | ||
180 | { | ||
181 | parcelIDList[x, y] = master.parcelData.localID; | ||
182 | } | ||
183 | } | ||
184 | } | ||
185 | removeParcel(slave.parcelData.localID); | ||
186 | } | ||
187 | /// <summary> | ||
188 | /// Get the parcel at the specified point | ||
189 | /// </summary> | ||
190 | /// <param name="x">Value between 0 - 256 on the x axis of the point</param> | ||
191 | /// <param name="y">Value between 0 - 256 on the y axis of the point</param> | ||
192 | /// <returns>Parcel at the point supplied</returns> | ||
193 | public Parcel getParcel(int x, int y) | ||
194 | { | ||
195 | if (x > 256 || y > 256 || x < 0 || y < 0) | ||
196 | { | ||
197 | throw new Exception("Error: Parcel not found at point " + x + ", " + y); | ||
198 | } | ||
199 | else | ||
200 | { | ||
201 | return parcelList[parcelIDList[x / 4, y / 4]]; | ||
202 | } | ||
203 | |||
204 | } | ||
205 | #endregion | ||
206 | |||
207 | #region Parcel Modification | ||
208 | /// <summary> | ||
209 | /// Subdivides a parcel | ||
210 | /// </summary> | ||
211 | /// <param name="start_x">West Point</param> | ||
212 | /// <param name="start_y">South Point</param> | ||
213 | /// <param name="end_x">East Point</param> | ||
214 | /// <param name="end_y">North Point</param> | ||
215 | /// <param name="attempting_user_id">LLUUID of user who is trying to subdivide</param> | ||
216 | /// <returns>Returns true if successful</returns> | ||
217 | private bool subdivide(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id) | ||
218 | { | ||
219 | //First, lets loop through the points and make sure they are all in the same parcel | ||
220 | //Get the parcel at start | ||
221 | Parcel startParcel = getParcel(start_x, start_y); | ||
222 | if (startParcel == null) return false; //No such parcel at the beginning | ||
223 | |||
224 | //Loop through the points | ||
225 | try | ||
226 | { | ||
227 | int totalX = end_x - start_x; | ||
228 | int totalY = end_y - start_y; | ||
229 | int x, y; | ||
230 | for (y = 0; y < totalY; y++) | ||
231 | { | ||
232 | for (x = 0; x < totalX; x++) | ||
233 | { | ||
234 | Parcel tempParcel = getParcel(start_x + x, start_y + y); | ||
235 | if (tempParcel == null) return false; //No such parcel at that point | ||
236 | if (tempParcel != startParcel) return false; //Subdividing over 2 parcels; no-no | ||
237 | } | ||
238 | } | ||
239 | } | ||
240 | catch (Exception) | ||
241 | { | ||
242 | return false; //Exception. For now, lets skip subdivision | ||
243 | } | ||
244 | |||
245 | //If we are still here, then they are subdividing within one parcel | ||
246 | //Check owner | ||
247 | if (startParcel.parcelData.ownerID != attempting_user_id) | ||
248 | { | ||
249 | return false; //They cant do this! | ||
250 | } | ||
251 | |||
252 | //Lets create a new parcel with bitmap activated at that point (keeping the old parcels info) | ||
253 | Parcel newParcel = startParcel.Copy(); | ||
254 | newParcel.parcelData.parcelName = "Subdivision of " + newParcel.parcelData.parcelName; | ||
255 | newParcel.parcelData.globalID = LLUUID.Random(); | ||
256 | |||
257 | newParcel.setParcelBitmap(Parcel.getSquareParcelBitmap(start_x, start_y, end_x, end_y)); | ||
258 | |||
259 | //Now, lets set the subdivision area of the original to false | ||
260 | int startParcelIndex = startParcel.parcelData.localID; | ||
261 | parcelList[startParcelIndex].setParcelBitmap(Parcel.modifyParcelBitmapSquare(startParcel.getParcelBitmap(), start_x, start_y, end_x, end_y, false)); | ||
262 | parcelList[startParcelIndex].forceUpdateParcelInfo(); | ||
263 | |||
264 | |||
265 | //Now add the new parcel | ||
266 | addParcel(newParcel); | ||
267 | |||
268 | |||
269 | |||
270 | |||
271 | |||
272 | return true; | ||
273 | } | ||
274 | /// <summary> | ||
275 | /// Join 2 parcels together | ||
276 | /// </summary> | ||
277 | /// <param name="start_x">x value in first parcel</param> | ||
278 | /// <param name="start_y">y value in first parcel</param> | ||
279 | /// <param name="end_x">x value in second parcel</param> | ||
280 | /// <param name="end_y">y value in second parcel</param> | ||
281 | /// <param name="attempting_user_id">LLUUID of the avatar trying to join the parcels</param> | ||
282 | /// <returns>Returns true if successful</returns> | ||
283 | private bool join(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id) | ||
284 | { | ||
285 | end_x -= 4; | ||
286 | end_y -= 4; | ||
287 | |||
288 | //NOTE: The following only connects the parcels in each corner and not all the parcels that are within the selection box! | ||
289 | //This should be fixed later -- somewhat "incomplete code" --Ming | ||
290 | Parcel startParcel, endParcel; | ||
291 | |||
292 | try | ||
293 | { | ||
294 | startParcel = getParcel(start_x, start_y); | ||
295 | endParcel = getParcel(end_x, end_y); | ||
296 | } | ||
297 | catch (Exception) | ||
298 | { | ||
299 | return false; //Error occured when trying to get the start and end parcels | ||
300 | } | ||
301 | if (startParcel == endParcel) | ||
302 | { | ||
303 | return false; //Subdivision of the same parcel is not allowed | ||
304 | } | ||
305 | |||
306 | //Check the parcel owners: | ||
307 | if (startParcel.parcelData.ownerID != endParcel.parcelData.ownerID) | ||
308 | { | ||
309 | return false; | ||
310 | } | ||
311 | if (startParcel.parcelData.ownerID != attempting_user_id) | ||
312 | { | ||
313 | //TODO: Group editing stuff. Avatar owner support for now | ||
314 | return false; | ||
315 | } | ||
316 | |||
317 | //Same owners! Lets join them | ||
318 | //Merge them to startParcel | ||
319 | parcelList[startParcel.parcelData.localID].setParcelBitmap(Parcel.mergeParcelBitmaps(startParcel.getParcelBitmap(), endParcel.getParcelBitmap())); | ||
320 | performFinalParcelJoin(startParcel, endParcel); | ||
321 | |||
322 | return true; | ||
323 | |||
324 | |||
325 | |||
326 | } | ||
327 | #endregion | ||
328 | |||
329 | #region Parcel Updating | ||
330 | /// <summary> | ||
331 | /// Where we send the ParcelOverlay packet to the client | ||
332 | /// </summary> | ||
333 | /// <param name="remote_client">The object representing the client</param> | ||
334 | public void sendParcelOverlay(IClientAPI remote_client) | ||
335 | { | ||
336 | const int PARCEL_BLOCKS_PER_PACKET = 1024; | ||
337 | int x, y = 0; | ||
338 | byte[] byteArray = new byte[PARCEL_BLOCKS_PER_PACKET]; | ||
339 | int byteArrayCount = 0; | ||
340 | int sequenceID = 0; | ||
341 | ParcelOverlayPacket packet; | ||
342 | |||
343 | for (y = 0; y < 64; y++) | ||
344 | { | ||
345 | for (x = 0; x < 64; x++) | ||
346 | { | ||
347 | byte tempByte = (byte)0; //This represents the byte for the current 4x4 | ||
348 | Parcel currentParcelBlock = getParcel(x * 4, y * 4); | ||
349 | |||
350 | if (currentParcelBlock.parcelData.ownerID == remote_client.AgentId) | ||
351 | { | ||
352 | //Owner Flag | ||
353 | tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_OWNED_BY_REQUESTER); | ||
354 | } | ||
355 | else if (currentParcelBlock.parcelData.salePrice > 0 && (currentParcelBlock.parcelData.authBuyerID == LLUUID.Zero || currentParcelBlock.parcelData.authBuyerID == remote_client.AgentId)) | ||
356 | { | ||
357 | //Sale Flag | ||
358 | tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_IS_FOR_SALE); | ||
359 | } | ||
360 | else if (currentParcelBlock.parcelData.ownerID == LLUUID.Zero) | ||
361 | { | ||
362 | //Public Flag | ||
363 | tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_PUBLIC); | ||
364 | } | ||
365 | else | ||
366 | { | ||
367 | //Other Flag | ||
368 | tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_OWNED_BY_OTHER); | ||
369 | } | ||
370 | |||
371 | |||
372 | //Now for border control | ||
373 | if (x == 0) | ||
374 | { | ||
375 | tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_WEST); | ||
376 | } | ||
377 | else if (getParcel((x - 1) * 4, y * 4) != currentParcelBlock) | ||
378 | { | ||
379 | tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_WEST); | ||
380 | } | ||
381 | |||
382 | if (y == 0) | ||
383 | { | ||
384 | tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_SOUTH); | ||
385 | } | ||
386 | else if (getParcel(x * 4, (y - 1) * 4) != currentParcelBlock) | ||
387 | { | ||
388 | tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_SOUTH); | ||
389 | } | ||
390 | |||
391 | byteArray[byteArrayCount] = tempByte; | ||
392 | byteArrayCount++; | ||
393 | if (byteArrayCount >= PARCEL_BLOCKS_PER_PACKET) | ||
394 | { | ||
395 | byteArrayCount = 0; | ||
396 | packet = new ParcelOverlayPacket(); | ||
397 | packet.ParcelData.Data = byteArray; | ||
398 | packet.ParcelData.SequenceID = sequenceID; | ||
399 | remote_client.OutPacket((Packet)packet); | ||
400 | sequenceID++; | ||
401 | byteArray = new byte[PARCEL_BLOCKS_PER_PACKET]; | ||
402 | } | ||
403 | } | ||
404 | } | ||
405 | |||
406 | packet = new ParcelOverlayPacket(); | ||
407 | packet.ParcelData.Data = byteArray; | ||
408 | packet.ParcelData.SequenceID = sequenceID; //Eh? | ||
409 | remote_client.OutPacket((Packet)packet); | ||
410 | } | ||
411 | |||
412 | public void handleParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id, bool snap_selection, IClientAPI remote_client) | ||
413 | { | ||
414 | //Get the parcels within the bounds | ||
415 | List<Parcel> temp = new List<Parcel>(); | ||
416 | int x, y, i; | ||
417 | int inc_x = end_x - start_x; | ||
418 | int inc_y = end_y - start_y; | ||
419 | for (x = 0; x < inc_x; x++) | ||
420 | { | ||
421 | for (y = 0; y < inc_y; y++) | ||
422 | { | ||
423 | OpenSim.Region.Parcel currentParcel = getParcel(start_x + x, start_y + y); | ||
424 | if (!temp.Contains(currentParcel)) | ||
425 | { | ||
426 | currentParcel.forceUpdateParcelInfo(); | ||
427 | temp.Add(currentParcel); | ||
428 | } | ||
429 | } | ||
430 | } | ||
431 | |||
432 | int requestResult = ParcelManager.PARCEL_RESULT_ONE_PARCEL; | ||
433 | if (temp.Count > 1) | ||
434 | { | ||
435 | requestResult = ParcelManager.PARCEL_RESULT_MULTIPLE_PARCELS; | ||
436 | } | ||
437 | |||
438 | for (i = 0; i < temp.Count; i++) | ||
439 | { | ||
440 | temp[i].sendParcelProperties(sequence_id, snap_selection, requestResult, remote_client); | ||
441 | } | ||
442 | |||
443 | |||
444 | sendParcelOverlay(remote_client); | ||
445 | } | ||
446 | |||
447 | public void handleParcelPropertiesUpdateRequest(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client) | ||
448 | { | ||
449 | if (parcelList.ContainsKey(packet.ParcelData.LocalID)) | ||
450 | { | ||
451 | parcelList[packet.ParcelData.LocalID].updateParcelProperties(packet, remote_client); | ||
452 | } | ||
453 | } | ||
454 | public void handleParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client) | ||
455 | { | ||
456 | subdivide(west, south, east, north, remote_client.AgentId); | ||
457 | } | ||
458 | public void handleParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client) | ||
459 | { | ||
460 | join(west, south, east, north, remote_client.AgentId); | ||
461 | |||
462 | } | ||
463 | #endregion | ||
464 | |||
465 | /// <summary> | ||
466 | /// Resets the sim to the default parcel (full sim parcel owned by the default user) | ||
467 | /// </summary> | ||
468 | public void resetSimParcels() | ||
469 | { | ||
470 | //Remove all the parcels in the sim and add a blank, full sim parcel set to public | ||
471 | parcelList.Clear(); | ||
472 | lastParcelLocalID = START_PARCEL_LOCAL_ID - 1; | ||
473 | parcelIDList.Initialize(); | ||
474 | |||
475 | Parcel fullSimParcel = new Parcel(LLUUID.Zero, false, m_world); | ||
476 | |||
477 | fullSimParcel.setParcelBitmap(Parcel.getSquareParcelBitmap(0, 0, 256, 256)); | ||
478 | fullSimParcel.parcelData.parcelName = "Your Sim Parcel"; | ||
479 | fullSimParcel.parcelData.parcelDesc = ""; | ||
480 | |||
481 | fullSimParcel.parcelData.ownerID = m_regInfo.MasterAvatarAssignedUUID; | ||
482 | fullSimParcel.parcelData.salePrice = 1; | ||
483 | fullSimParcel.parcelData.parcelFlags = libsecondlife.Parcel.ParcelFlags.ForSale; | ||
484 | fullSimParcel.parcelData.parcelStatus = libsecondlife.Parcel.ParcelStatus.Leased; | ||
485 | |||
486 | addParcel(fullSimParcel); | ||
487 | |||
488 | } | ||
489 | #endregion | ||
490 | } | ||
491 | #endregion | ||
492 | |||
493 | |||
494 | #region Parcel Class | ||
495 | /// <summary> | ||
496 | /// Keeps track of a specific parcel's information | ||
497 | /// </summary> | ||
498 | public class Parcel | ||
499 | { | ||
500 | #region Member Variables | ||
501 | public ParcelData parcelData = new ParcelData(); | ||
502 | public Scene m_world; | ||
503 | |||
504 | private bool[,] parcelBitmap = new bool[64, 64]; | ||
505 | |||
506 | #endregion | ||
507 | |||
508 | |||
509 | #region Constructors | ||
510 | public Parcel(LLUUID owner_id, bool is_group_owned, Scene world) | ||
511 | { | ||
512 | m_world = world; | ||
513 | parcelData.ownerID = owner_id; | ||
514 | parcelData.isGroupOwned = is_group_owned; | ||
515 | |||
516 | } | ||
517 | #endregion | ||
518 | |||
519 | |||
520 | #region Member Functions | ||
521 | |||
522 | #region General Functions | ||
523 | /// <summary> | ||
524 | /// Checks to see if this parcel contains a point | ||
525 | /// </summary> | ||
526 | /// <param name="x"></param> | ||
527 | /// <param name="y"></param> | ||
528 | /// <returns>Returns true if the parcel contains the specified point</returns> | ||
529 | public bool containsPoint(int x, int y) | ||
530 | { | ||
531 | if (x >= 0 && y >= 0 && x <= 256 && x <= 256) | ||
532 | { | ||
533 | return (parcelBitmap[x / 4, y / 4] == true); | ||
534 | } | ||
535 | else | ||
536 | { | ||
537 | return false; | ||
538 | } | ||
539 | } | ||
540 | |||
541 | public Parcel Copy() | ||
542 | { | ||
543 | Parcel newParcel = new Parcel(this.parcelData.ownerID, this.parcelData.isGroupOwned, m_world); | ||
544 | |||
545 | //Place all new variables here! | ||
546 | newParcel.parcelBitmap = (bool[,])(this.parcelBitmap.Clone()); | ||
547 | newParcel.parcelData = parcelData.Copy(); | ||
548 | |||
549 | return newParcel; | ||
550 | } | ||
551 | |||
552 | #endregion | ||
553 | |||
554 | |||
555 | #region Packet Request Handling | ||
556 | /// <summary> | ||
557 | /// Sends parcel properties as requested | ||
558 | /// </summary> | ||
559 | /// <param name="sequence_id">ID sent by client for them to keep track of</param> | ||
560 | /// <param name="snap_selection">Bool sent by client for them to use</param> | ||
561 | /// <param name="remote_client">Object representing the client</param> | ||
562 | public void sendParcelProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client) | ||
563 | { | ||
564 | |||
565 | ParcelPropertiesPacket updatePacket = new ParcelPropertiesPacket(); | ||
566 | updatePacket.ParcelData.AABBMax = parcelData.AABBMax; | ||
567 | updatePacket.ParcelData.AABBMin = parcelData.AABBMin; | ||
568 | updatePacket.ParcelData.Area = parcelData.area; | ||
569 | updatePacket.ParcelData.AuctionID = parcelData.auctionID; | ||
570 | updatePacket.ParcelData.AuthBuyerID = parcelData.authBuyerID; //unemplemented | ||
571 | |||
572 | updatePacket.ParcelData.Bitmap = parcelData.parcelBitmapByteArray; | ||
573 | |||
574 | updatePacket.ParcelData.Desc = libsecondlife.Helpers.StringToField(parcelData.parcelDesc); | ||
575 | updatePacket.ParcelData.Category = (byte)parcelData.category; | ||
576 | updatePacket.ParcelData.ClaimDate = parcelData.claimDate; | ||
577 | updatePacket.ParcelData.ClaimPrice = parcelData.claimPrice; | ||
578 | updatePacket.ParcelData.GroupID = parcelData.groupID; | ||
579 | updatePacket.ParcelData.GroupPrims = parcelData.groupPrims; | ||
580 | updatePacket.ParcelData.IsGroupOwned = parcelData.isGroupOwned; | ||
581 | updatePacket.ParcelData.LandingType = (byte)parcelData.landingType; | ||
582 | updatePacket.ParcelData.LocalID = parcelData.localID; | ||
583 | updatePacket.ParcelData.MaxPrims = 1000; //unemplemented | ||
584 | updatePacket.ParcelData.MediaAutoScale = parcelData.mediaAutoScale; | ||
585 | updatePacket.ParcelData.MediaID = parcelData.mediaID; | ||
586 | updatePacket.ParcelData.MediaURL = Helpers.StringToField(parcelData.mediaURL); | ||
587 | updatePacket.ParcelData.MusicURL = Helpers.StringToField(parcelData.musicURL); | ||
588 | updatePacket.ParcelData.Name = Helpers.StringToField(parcelData.parcelName); | ||
589 | updatePacket.ParcelData.OtherCleanTime = 0; //unemplemented | ||
590 | updatePacket.ParcelData.OtherCount = 0; //unemplemented | ||
591 | updatePacket.ParcelData.OtherPrims = 0; //unemplented | ||
592 | updatePacket.ParcelData.OwnerID = parcelData.ownerID; | ||
593 | updatePacket.ParcelData.OwnerPrims = 0; //unemplemented | ||
594 | updatePacket.ParcelData.ParcelFlags = (uint)parcelData.parcelFlags; //unemplemented | ||
595 | updatePacket.ParcelData.ParcelPrimBonus = (float)1.0; //unemplemented | ||
596 | updatePacket.ParcelData.PassHours = parcelData.passHours; | ||
597 | updatePacket.ParcelData.PassPrice = parcelData.passPrice; | ||
598 | updatePacket.ParcelData.PublicCount = 0; //unemplemented | ||
599 | updatePacket.ParcelData.RegionDenyAnonymous = false; //unemplemented | ||
600 | updatePacket.ParcelData.RegionDenyIdentified = false; //unemplemented | ||
601 | updatePacket.ParcelData.RegionDenyTransacted = false; //unemplemented | ||
602 | updatePacket.ParcelData.RegionPushOverride = true; //unemplemented | ||
603 | updatePacket.ParcelData.RentPrice = 0; //?? | ||
604 | updatePacket.ParcelData.RequestResult = request_result; | ||
605 | updatePacket.ParcelData.SalePrice = parcelData.salePrice; //unemplemented | ||
606 | updatePacket.ParcelData.SelectedPrims = 0; //unemeplemented | ||
607 | updatePacket.ParcelData.SelfCount = 0;//unemplemented | ||
608 | updatePacket.ParcelData.SequenceID = sequence_id; | ||
609 | updatePacket.ParcelData.SimWideMaxPrims = 15000; //unemplemented | ||
610 | updatePacket.ParcelData.SimWideTotalPrims = 0; //unemplemented | ||
611 | updatePacket.ParcelData.SnapSelection = snap_selection; | ||
612 | updatePacket.ParcelData.SnapshotID = parcelData.snapshotID; | ||
613 | updatePacket.ParcelData.Status = (byte)parcelData.parcelStatus; | ||
614 | updatePacket.ParcelData.TotalPrims = 0; //unemplemented | ||
615 | updatePacket.ParcelData.UserLocation = parcelData.userLocation; | ||
616 | updatePacket.ParcelData.UserLookAt = parcelData.userLookAt; | ||
617 | remote_client.OutPacket((Packet)updatePacket); | ||
618 | } | ||
619 | |||
620 | public void updateParcelProperties(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client) | ||
621 | { | ||
622 | if (remote_client.AgentId == parcelData.ownerID) | ||
623 | { | ||
624 | //Needs later group support | ||
625 | parcelData.authBuyerID = packet.ParcelData.AuthBuyerID; | ||
626 | parcelData.category = (libsecondlife.Parcel.ParcelCategory)packet.ParcelData.Category; | ||
627 | parcelData.parcelDesc = Helpers.FieldToUTF8String(packet.ParcelData.Desc); | ||
628 | parcelData.groupID = packet.ParcelData.GroupID; | ||
629 | parcelData.landingType = packet.ParcelData.LandingType; | ||
630 | parcelData.mediaAutoScale = packet.ParcelData.MediaAutoScale; | ||
631 | parcelData.mediaID = packet.ParcelData.MediaID; | ||
632 | parcelData.mediaURL = Helpers.FieldToUTF8String(packet.ParcelData.MediaURL); | ||
633 | parcelData.musicURL = Helpers.FieldToUTF8String(packet.ParcelData.MusicURL); | ||
634 | parcelData.parcelName = libsecondlife.Helpers.FieldToUTF8String(packet.ParcelData.Name); | ||
635 | parcelData.parcelFlags = (libsecondlife.Parcel.ParcelFlags)packet.ParcelData.ParcelFlags; | ||
636 | parcelData.passHours = packet.ParcelData.PassHours; | ||
637 | parcelData.passPrice = packet.ParcelData.PassPrice; | ||
638 | parcelData.salePrice = packet.ParcelData.SalePrice; | ||
639 | parcelData.snapshotID = packet.ParcelData.SnapshotID; | ||
640 | parcelData.userLocation = packet.ParcelData.UserLocation; | ||
641 | parcelData.userLookAt = packet.ParcelData.UserLookAt; | ||
642 | |||
643 | List<Avatar> avatars = m_world.RequestAvatarList(); | ||
644 | |||
645 | for (int i = 0; i < avatars.Count; i++) | ||
646 | { | ||
647 | Parcel over = m_world.parcelManager.getParcel((int)Math.Round(avatars[i].Pos.X), (int)Math.Round(avatars[i].Pos.Y)); | ||
648 | if (over == this) | ||
649 | { | ||
650 | sendParcelProperties(0, false, 0, avatars[i].ControllingClient); | ||
651 | } | ||
652 | } | ||
653 | |||
654 | } | ||
655 | } | ||
656 | #endregion | ||
657 | |||
658 | |||
659 | #region Update Functions | ||
660 | /// <summary> | ||
661 | /// Updates the AABBMin and AABBMax values after area/shape modification of parcel | ||
662 | /// </summary> | ||
663 | private void updateAABBAndAreaValues() | ||
664 | { | ||
665 | int min_x = 64; | ||
666 | int min_y = 64; | ||
667 | int max_x = 0; | ||
668 | int max_y = 0; | ||
669 | int tempArea = 0; | ||
670 | int x, y; | ||
671 | for (x = 0; x < 64; x++) | ||
672 | { | ||
673 | for (y = 0; y < 64; y++) | ||
674 | { | ||
675 | if (parcelBitmap[x, y] == true) | ||
676 | { | ||
677 | if (min_x > x) min_x = x; | ||
678 | if (min_y > y) min_y = y; | ||
679 | if (max_x < x) max_x = x; | ||
680 | if (max_y < y) max_y = y; | ||
681 | tempArea += 16; //16sqm parcel | ||
682 | } | ||
683 | } | ||
684 | } | ||
685 | parcelData.AABBMin = new LLVector3((float)(min_x * 4), (float)(min_y * 4), m_world.Terrain[(min_x * 4), (min_y * 4)]); | ||
686 | parcelData.AABBMax = new LLVector3((float)(max_x * 4), (float)(max_y * 4), m_world.Terrain[(max_x * 4), (max_y * 4)]); | ||
687 | parcelData.area = tempArea; | ||
688 | } | ||
689 | |||
690 | public void updateParcelBitmapByteArray() | ||
691 | { | ||
692 | parcelData.parcelBitmapByteArray = convertParcelBitmapToBytes(); | ||
693 | } | ||
694 | |||
695 | /// <summary> | ||
696 | /// Update all settings in parcel such as area, bitmap byte array, etc | ||
697 | /// </summary> | ||
698 | public void forceUpdateParcelInfo() | ||
699 | { | ||
700 | this.updateAABBAndAreaValues(); | ||
701 | this.updateParcelBitmapByteArray(); | ||
702 | } | ||
703 | |||
704 | public void setParcelBitmapFromByteArray() | ||
705 | { | ||
706 | parcelBitmap = convertBytesToParcelBitmap(); | ||
707 | } | ||
708 | #endregion | ||
709 | |||
710 | |||
711 | #region Parcel Bitmap Functions | ||
712 | /// <summary> | ||
713 | /// Sets the parcel's bitmap manually | ||
714 | /// </summary> | ||
715 | /// <param name="bitmap">64x64 block representing where this parcel is on a map</param> | ||
716 | public void setParcelBitmap(bool[,] bitmap) | ||
717 | { | ||
718 | if (bitmap.GetLength(0) != 64 || bitmap.GetLength(1) != 64 || bitmap.Rank != 2) | ||
719 | { | ||
720 | //Throw an exception - The bitmap is not 64x64 | ||
721 | throw new Exception("Error: Invalid Parcel Bitmap"); | ||
722 | } | ||
723 | else | ||
724 | { | ||
725 | //Valid: Lets set it | ||
726 | parcelBitmap = bitmap; | ||
727 | forceUpdateParcelInfo(); | ||
728 | |||
729 | } | ||
730 | } | ||
731 | /// <summary> | ||
732 | /// Gets the parcels bitmap manually | ||
733 | /// </summary> | ||
734 | /// <returns></returns> | ||
735 | public bool[,] getParcelBitmap() | ||
736 | { | ||
737 | return parcelBitmap; | ||
738 | } | ||
739 | /// <summary> | ||
740 | /// Converts the parcel bitmap to a packet friendly byte array | ||
741 | /// </summary> | ||
742 | /// <returns></returns> | ||
743 | private byte[] convertParcelBitmapToBytes() | ||
744 | { | ||
745 | byte[] tempConvertArr = new byte[512]; | ||
746 | byte tempByte = 0; | ||
747 | int x, y, i, byteNum = 0; | ||
748 | i = 0; | ||
749 | for (y = 0; y < 64; y++) | ||
750 | { | ||
751 | for (x = 0; x < 64; x++) | ||
752 | { | ||
753 | tempByte = Convert.ToByte(tempByte | Convert.ToByte(parcelBitmap[x, y]) << (i++ % 8)); | ||
754 | if (i % 8 == 0) | ||
755 | { | ||
756 | tempConvertArr[byteNum] = tempByte; | ||
757 | tempByte = (byte)0; | ||
758 | i = 0; | ||
759 | byteNum++; | ||
760 | } | ||
761 | } | ||
762 | } | ||
763 | return tempConvertArr; | ||
764 | } | ||
765 | |||
766 | private bool[,] convertBytesToParcelBitmap() | ||
767 | { | ||
768 | bool[,] tempConvertMap = new bool[64, 64]; | ||
769 | tempConvertMap.Initialize(); | ||
770 | byte tempByte = 0; | ||
771 | int x = 0, y = 0, i = 0, bitNum = 0; | ||
772 | for (i = 0; i < 512; i++) | ||
773 | { | ||
774 | tempByte = parcelData.parcelBitmapByteArray[i]; | ||
775 | for (bitNum = 0; bitNum < 8; bitNum++) | ||
776 | { | ||
777 | bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte)1); | ||
778 | tempConvertMap[x, y] = bit; | ||
779 | x++; | ||
780 | if (x > 63) | ||
781 | { | ||
782 | x = 0; | ||
783 | y++; | ||
784 | } | ||
785 | |||
786 | } | ||
787 | |||
788 | } | ||
789 | return tempConvertMap; | ||
790 | } | ||
791 | /// <summary> | ||
792 | /// Full sim parcel creation | ||
793 | /// </summary> | ||
794 | /// <returns></returns> | ||
795 | public static bool[,] basicFullRegionParcelBitmap() | ||
796 | { | ||
797 | return getSquareParcelBitmap(0, 0, 256, 256); | ||
798 | } | ||
799 | |||
800 | /// <summary> | ||
801 | /// Used to modify the bitmap between the x and y points. Points use 64 scale | ||
802 | /// </summary> | ||
803 | /// <param name="start_x"></param> | ||
804 | /// <param name="start_y"></param> | ||
805 | /// <param name="end_x"></param> | ||
806 | /// <param name="end_y"></param> | ||
807 | /// <returns></returns> | ||
808 | public static bool[,] getSquareParcelBitmap(int start_x, int start_y, int end_x, int end_y) | ||
809 | { | ||
810 | |||
811 | bool[,] tempBitmap = new bool[64, 64]; | ||
812 | tempBitmap.Initialize(); | ||
813 | |||
814 | tempBitmap = modifyParcelBitmapSquare(tempBitmap, start_x, start_y, end_x, end_y, true); | ||
815 | return tempBitmap; | ||
816 | } | ||
817 | |||
818 | /// <summary> | ||
819 | /// Change a parcel's bitmap at within a square and set those points to a specific value | ||
820 | /// </summary> | ||
821 | /// <param name="parcel_bitmap"></param> | ||
822 | /// <param name="start_x"></param> | ||
823 | /// <param name="start_y"></param> | ||
824 | /// <param name="end_x"></param> | ||
825 | /// <param name="end_y"></param> | ||
826 | /// <param name="set_value"></param> | ||
827 | /// <returns></returns> | ||
828 | public static bool[,] modifyParcelBitmapSquare(bool[,] parcel_bitmap, int start_x, int start_y, int end_x, int end_y, bool set_value) | ||
829 | { | ||
830 | if (parcel_bitmap.GetLength(0) != 64 || parcel_bitmap.GetLength(1) != 64 || parcel_bitmap.Rank != 2) | ||
831 | { | ||
832 | //Throw an exception - The bitmap is not 64x64 | ||
833 | throw new Exception("Error: Invalid Parcel Bitmap in modifyParcelBitmapSquare()"); | ||
834 | } | ||
835 | |||
836 | int x, y; | ||
837 | for (y = 0; y < 64; y++) | ||
838 | { | ||
839 | for (x = 0; x < 64; x++) | ||
840 | { | ||
841 | if (x >= start_x / 4 && x < end_x / 4 | ||
842 | && y >= start_y / 4 && y < end_y / 4) | ||
843 | { | ||
844 | parcel_bitmap[x, y] = set_value; | ||
845 | } | ||
846 | } | ||
847 | } | ||
848 | return parcel_bitmap; | ||
849 | } | ||
850 | /// <summary> | ||
851 | /// Join the true values of 2 bitmaps together | ||
852 | /// </summary> | ||
853 | /// <param name="bitmap_base"></param> | ||
854 | /// <param name="bitmap_add"></param> | ||
855 | /// <returns></returns> | ||
856 | public static bool[,] mergeParcelBitmaps(bool[,] bitmap_base, bool[,] bitmap_add) | ||
857 | { | ||
858 | if (bitmap_base.GetLength(0) != 64 || bitmap_base.GetLength(1) != 64 || bitmap_base.Rank != 2) | ||
859 | { | ||
860 | //Throw an exception - The bitmap is not 64x64 | ||
861 | throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_base in mergeParcelBitmaps"); | ||
862 | } | ||
863 | if (bitmap_add.GetLength(0) != 64 || bitmap_add.GetLength(1) != 64 || bitmap_add.Rank != 2) | ||
864 | { | ||
865 | //Throw an exception - The bitmap is not 64x64 | ||
866 | throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_add in mergeParcelBitmaps"); | ||
867 | |||
868 | } | ||
869 | |||
870 | int x, y; | ||
871 | for (y = 0; y < 64; y++) | ||
872 | { | ||
873 | for (x = 0; x < 64; x++) | ||
874 | { | ||
875 | if (bitmap_add[x, y]) | ||
876 | { | ||
877 | bitmap_base[x, y] = true; | ||
878 | } | ||
879 | } | ||
880 | } | ||
881 | return bitmap_base; | ||
882 | } | ||
883 | #endregion | ||
884 | |||
885 | #endregion | ||
886 | |||
887 | |||
888 | } | ||
889 | #endregion | ||
890 | |||
891 | |||
892 | } | ||
diff --git a/OpenSim/OpenSim.Region/RegionManager.cs b/OpenSim/OpenSim.Region/RegionManager.cs deleted file mode 100644 index a317f0f..0000000 --- a/OpenSim/OpenSim.Region/RegionManager.cs +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenGrid.Framework.Communications; | ||
5 | using OpenSim.Framework; | ||
6 | using OpenSim.Framework.Types; | ||
7 | using OpenSim.Servers; | ||
8 | |||
9 | namespace OpenSim.Region | ||
10 | { | ||
11 | public class RegionManager //needs renaming , but first we need to rename the namespace | ||
12 | { | ||
13 | protected AuthenticateSessionsBase authenticateHandler; | ||
14 | protected RegionCommsListener regionCommsHost; | ||
15 | protected CommunicationsManager commsManager; | ||
16 | protected List<Caps> capsHandlers = new List<Caps>(); | ||
17 | protected BaseHttpServer httpListener; | ||
18 | |||
19 | protected Scenes.Scene m_Scene; | ||
20 | |||
21 | public ParcelManager parcelManager; | ||
22 | public EstateManager estateManager; | ||
23 | |||
24 | public RegionManager() | ||
25 | { | ||
26 | |||
27 | } | ||
28 | |||
29 | } | ||
30 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/Entity.cs b/OpenSim/OpenSim.Region/Scenes/Entity.cs deleted file mode 100644 index 77f8854..0000000 --- a/OpenSim/OpenSim.Region/Scenes/Entity.cs +++ /dev/null | |||
@@ -1,193 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.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.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using Axiom.MathLib; | ||
32 | using OpenSim.Physics.Manager; | ||
33 | using libsecondlife; | ||
34 | |||
35 | namespace OpenSim.Region.Scenes | ||
36 | { | ||
37 | public abstract class Entity | ||
38 | { | ||
39 | public libsecondlife.LLUUID uuid; | ||
40 | public Quaternion rotation; | ||
41 | protected List<Entity> children; | ||
42 | |||
43 | protected PhysicsActor _physActor; | ||
44 | protected Scene m_world; | ||
45 | protected string m_name; | ||
46 | |||
47 | /// <summary> | ||
48 | /// | ||
49 | /// </summary> | ||
50 | public virtual string Name | ||
51 | { | ||
52 | get { return m_name; } | ||
53 | } | ||
54 | |||
55 | protected LLVector3 m_pos; | ||
56 | /// <summary> | ||
57 | /// | ||
58 | /// </summary> | ||
59 | public virtual LLVector3 Pos | ||
60 | { | ||
61 | get | ||
62 | { | ||
63 | if (this._physActor != null) | ||
64 | { | ||
65 | m_pos.X = _physActor.Position.X; | ||
66 | m_pos.Y = _physActor.Position.Y; | ||
67 | m_pos.Z = _physActor.Position.Z; | ||
68 | } | ||
69 | |||
70 | return m_pos; | ||
71 | } | ||
72 | set | ||
73 | { | ||
74 | if (this._physActor != null) | ||
75 | { | ||
76 | try | ||
77 | { | ||
78 | lock (this.m_world.SyncRoot) | ||
79 | { | ||
80 | |||
81 | this._physActor.Position = new PhysicsVector(value.X, value.Y, value.Z); | ||
82 | } | ||
83 | } | ||
84 | catch (Exception e) | ||
85 | { | ||
86 | Console.WriteLine(e.Message); | ||
87 | } | ||
88 | } | ||
89 | |||
90 | m_pos = value; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | public LLVector3 velocity; | ||
95 | |||
96 | /// <summary> | ||
97 | /// | ||
98 | /// </summary> | ||
99 | public virtual LLVector3 Velocity | ||
100 | { | ||
101 | get | ||
102 | { | ||
103 | if (this._physActor != null) | ||
104 | { | ||
105 | velocity.X = _physActor.Velocity.X; | ||
106 | velocity.Y = _physActor.Velocity.Y; | ||
107 | velocity.Z = _physActor.Velocity.Z; | ||
108 | } | ||
109 | |||
110 | return velocity; | ||
111 | } | ||
112 | set | ||
113 | { | ||
114 | if (this._physActor != null) | ||
115 | { | ||
116 | try | ||
117 | { | ||
118 | lock (this.m_world.SyncRoot) | ||
119 | { | ||
120 | |||
121 | this._physActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); | ||
122 | } | ||
123 | } | ||
124 | catch (Exception e) | ||
125 | { | ||
126 | Console.WriteLine(e.Message); | ||
127 | } | ||
128 | } | ||
129 | |||
130 | velocity = value; | ||
131 | } | ||
132 | } | ||
133 | |||
134 | protected uint m_localId; | ||
135 | |||
136 | public uint LocalId | ||
137 | { | ||
138 | get { return m_localId; } | ||
139 | } | ||
140 | |||
141 | /// <summary> | ||
142 | /// Creates a new Entity (should not occur on it's own) | ||
143 | /// </summary> | ||
144 | public Entity() | ||
145 | { | ||
146 | uuid = new libsecondlife.LLUUID(); | ||
147 | |||
148 | m_pos = new LLVector3(); | ||
149 | velocity = new LLVector3(); | ||
150 | rotation = new Quaternion(); | ||
151 | m_name = "(basic entity)"; | ||
152 | children = new List<Entity>(); | ||
153 | } | ||
154 | |||
155 | /// <summary> | ||
156 | /// | ||
157 | /// </summary> | ||
158 | public virtual void updateMovement() | ||
159 | { | ||
160 | foreach (Entity child in children) | ||
161 | { | ||
162 | child.updateMovement(); | ||
163 | } | ||
164 | } | ||
165 | |||
166 | /// <summary> | ||
167 | /// Performs any updates that need to be done at each frame. This function is overridable from it's children. | ||
168 | /// </summary> | ||
169 | public virtual void update() { | ||
170 | // Do any per-frame updates needed that are applicable to every type of entity | ||
171 | foreach (Entity child in children) | ||
172 | { | ||
173 | child.update(); | ||
174 | } | ||
175 | } | ||
176 | |||
177 | /// <summary> | ||
178 | /// Called at a set interval to inform entities that they should back themsleves up to the DB | ||
179 | /// </summary> | ||
180 | public virtual void BackUp() | ||
181 | { | ||
182 | |||
183 | } | ||
184 | |||
185 | /// <summary> | ||
186 | /// Infoms the entity that the land (heightmap) has changed | ||
187 | /// </summary> | ||
188 | public virtual void LandRenegerated() | ||
189 | { | ||
190 | |||
191 | } | ||
192 | } | ||
193 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/IScenePresenceBody.cs b/OpenSim/OpenSim.Region/Scenes/IScenePresenceBody.cs deleted file mode 100644 index 65077e6..0000000 --- a/OpenSim/OpenSim.Region/Scenes/IScenePresenceBody.cs +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using libsecondlife; | ||
5 | using libsecondlife.Packets; | ||
6 | using OpenSim.Physics.Manager; | ||
7 | using OpenSim.Framework.Interfaces; | ||
8 | using OpenSim.Framework.Types; | ||
9 | |||
10 | namespace OpenSim.Region.Scenes | ||
11 | { | ||
12 | public interface IScenePresenceBody | ||
13 | { | ||
14 | void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation); | ||
15 | void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam); | ||
16 | void SendOurAppearance(IClientAPI OurClient); | ||
17 | void SendAppearanceToOtherAgent(ScenePresence avatarInfo); | ||
18 | } | ||
19 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/Primitive.cs b/OpenSim/OpenSim.Region/Scenes/Primitive.cs deleted file mode 100644 index e04c711..0000000 --- a/OpenSim/OpenSim.Region/Scenes/Primitive.cs +++ /dev/null | |||
@@ -1,582 +0,0 @@ | |||
1 | |||
2 | /* | ||
3 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
4 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions are met: | ||
8 | * * Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * * Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * * Neither the name of the OpenSim Project nor the | ||
14 | * names of its contributors may be used to endorse or promote products | ||
15 | * derived from this software without specific prior written permission. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
20 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
27 | * | ||
28 | */ | ||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Text; | ||
32 | using libsecondlife; | ||
33 | using libsecondlife.Packets; | ||
34 | using OpenSim.Framework.Interfaces; | ||
35 | using OpenSim.Physics.Manager; | ||
36 | using OpenSim.Framework.Types; | ||
37 | using OpenSim.Framework.Inventory; | ||
38 | |||
39 | namespace OpenSim.Region.Scenes | ||
40 | { | ||
41 | public class Primitive : Entity | ||
42 | { | ||
43 | internal PrimData primData; | ||
44 | private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); | ||
45 | // private Dictionary<uint, IClientAPI> m_clientThreads; | ||
46 | private ulong m_regionHandle; | ||
47 | private const uint FULL_MASK_PERMISSIONS = 2147483647; | ||
48 | private bool physicsEnabled = false; | ||
49 | private byte updateFlag = 0; | ||
50 | private uint flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128; | ||
51 | |||
52 | private Dictionary<LLUUID, InventoryItem> inventoryItems; | ||
53 | |||
54 | #region Properties | ||
55 | |||
56 | public LLVector3 Scale | ||
57 | { | ||
58 | set | ||
59 | { | ||
60 | this.primData.Scale = value; | ||
61 | //this.dirtyFlag = true; | ||
62 | } | ||
63 | get | ||
64 | { | ||
65 | return this.primData.Scale; | ||
66 | } | ||
67 | } | ||
68 | |||
69 | public PhysicsActor PhysActor | ||
70 | { | ||
71 | set | ||
72 | { | ||
73 | this._physActor = value; | ||
74 | } | ||
75 | } | ||
76 | |||
77 | public override LLVector3 Pos | ||
78 | { | ||
79 | get | ||
80 | { | ||
81 | return base.Pos; | ||
82 | } | ||
83 | set | ||
84 | { | ||
85 | base.Pos = value; | ||
86 | } | ||
87 | } | ||
88 | #endregion | ||
89 | |||
90 | /// <summary> | ||
91 | /// | ||
92 | /// </summary> | ||
93 | /// <param name="clientThreads"></param> | ||
94 | /// <param name="regionHandle"></param> | ||
95 | /// <param name="world"></param> | ||
96 | public Primitive( ulong regionHandle, Scene world) | ||
97 | { | ||
98 | // m_clientThreads = clientThreads; | ||
99 | m_regionHandle = regionHandle; | ||
100 | m_world = world; | ||
101 | inventoryItems = new Dictionary<LLUUID, InventoryItem>(); | ||
102 | } | ||
103 | |||
104 | /// <summary> | ||
105 | /// | ||
106 | /// </summary> | ||
107 | /// <param name="regionHandle"></param> | ||
108 | /// <param name="world"></param> | ||
109 | /// <param name="addPacket"></param> | ||
110 | /// <param name="ownerID"></param> | ||
111 | /// <param name="localID"></param> | ||
112 | public Primitive(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID) | ||
113 | { | ||
114 | // m_clientThreads = clientThreads; | ||
115 | m_regionHandle = regionHandle; | ||
116 | m_world = world; | ||
117 | inventoryItems = new Dictionary<LLUUID, InventoryItem>(); | ||
118 | this.CreateFromPacket(addPacket, ownerID, localID); | ||
119 | } | ||
120 | |||
121 | /// <summary> | ||
122 | /// | ||
123 | /// </summary> | ||
124 | /// <param name="clientThreads"></param> | ||
125 | /// <param name="regionHandle"></param> | ||
126 | /// <param name="world"></param> | ||
127 | /// <param name="owner"></param> | ||
128 | /// <param name="fullID"></param> | ||
129 | /// <param name="localID"></param> | ||
130 | public Primitive( ulong regionHandle, Scene world, LLUUID owner, LLUUID fullID, uint localID) | ||
131 | { | ||
132 | // m_clientThreads = clientThreads; | ||
133 | m_regionHandle = regionHandle; | ||
134 | m_world = world; | ||
135 | inventoryItems = new Dictionary<LLUUID, InventoryItem>(); | ||
136 | this.primData = new PrimData(); | ||
137 | this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | ||
138 | this.primData.OwnerID = owner; | ||
139 | this.primData.FullID = this.uuid = fullID; | ||
140 | this.primData.LocalID = m_localId = localID; | ||
141 | } | ||
142 | |||
143 | /// <summary> | ||
144 | /// Constructor to create a default cube | ||
145 | /// </summary> | ||
146 | /// <param name="clientThreads"></param> | ||
147 | /// <param name="regionHandle"></param> | ||
148 | /// <param name="world"></param> | ||
149 | /// <param name="owner"></param> | ||
150 | /// <param name="localID"></param> | ||
151 | /// <param name="position"></param> | ||
152 | public Primitive( ulong regionHandle, Scene world, LLUUID owner, uint localID, LLVector3 position) | ||
153 | { | ||
154 | //m_clientThreads = clientThreads; | ||
155 | m_regionHandle = regionHandle; | ||
156 | m_world = world; | ||
157 | inventoryItems = new Dictionary<LLUUID, InventoryItem>(); | ||
158 | this.primData = PrimData.DefaultCube(); | ||
159 | this.primData.OwnerID = owner; | ||
160 | this.primData.LocalID = m_localId = localID; | ||
161 | this.Pos = this.primData.Position = position; | ||
162 | |||
163 | this.updateFlag = 1; | ||
164 | } | ||
165 | |||
166 | /// <summary> | ||
167 | /// | ||
168 | /// </summary> | ||
169 | /// <returns></returns> | ||
170 | public byte[] GetByteArray() | ||
171 | { | ||
172 | byte[] result = null; | ||
173 | List<byte[]> dataArrays = new List<byte[]>(); | ||
174 | dataArrays.Add(primData.ToBytes()); | ||
175 | foreach (Entity child in children) | ||
176 | { | ||
177 | if (child is OpenSim.Region.Scenes.Primitive) | ||
178 | { | ||
179 | dataArrays.Add(((OpenSim.Region.Scenes.Primitive)child).GetByteArray()); | ||
180 | } | ||
181 | } | ||
182 | byte[] primstart = Helpers.StringToField("<Prim>"); | ||
183 | byte[] primend = Helpers.StringToField("</Prim>"); | ||
184 | int totalLength = primstart.Length + primend.Length; | ||
185 | for (int i = 0; i < dataArrays.Count; i++) | ||
186 | { | ||
187 | totalLength += dataArrays[i].Length; | ||
188 | } | ||
189 | |||
190 | result = new byte[totalLength]; | ||
191 | int arraypos = 0; | ||
192 | Array.Copy(primstart, 0, result, 0, primstart.Length); | ||
193 | arraypos += primstart.Length; | ||
194 | for (int i = 0; i < dataArrays.Count; i++) | ||
195 | { | ||
196 | Array.Copy(dataArrays[i], 0, result, arraypos, dataArrays[i].Length); | ||
197 | arraypos += dataArrays[i].Length; | ||
198 | } | ||
199 | Array.Copy(primend, 0, result, arraypos, primend.Length); | ||
200 | |||
201 | return result; | ||
202 | } | ||
203 | |||
204 | #region Overridden Methods | ||
205 | |||
206 | /// <summary> | ||
207 | /// | ||
208 | /// </summary> | ||
209 | public override void update() | ||
210 | { | ||
211 | if (this.updateFlag == 1) // is a new prim just been created/reloaded | ||
212 | { | ||
213 | this.SendFullUpdateToAllClients(); | ||
214 | this.updateFlag = 0; | ||
215 | } | ||
216 | if (this.updateFlag == 2) //some change has been made so update the clients | ||
217 | { | ||
218 | this.SendTerseUpdateToALLClients(); | ||
219 | this.updateFlag = 0; | ||
220 | } | ||
221 | } | ||
222 | |||
223 | /// <summary> | ||
224 | /// | ||
225 | /// </summary> | ||
226 | public override void BackUp() | ||
227 | { | ||
228 | |||
229 | } | ||
230 | |||
231 | #endregion | ||
232 | |||
233 | #region Packet handlers | ||
234 | |||
235 | /// <summary> | ||
236 | /// | ||
237 | /// </summary> | ||
238 | /// <param name="pos"></param> | ||
239 | public void UpdatePosition(LLVector3 pos) | ||
240 | { | ||
241 | this.Pos = new LLVector3(pos.X, pos.Y, pos.Z); | ||
242 | this.updateFlag = 2; | ||
243 | } | ||
244 | |||
245 | /// <summary> | ||
246 | /// | ||
247 | /// </summary> | ||
248 | /// <param name="addPacket"></param> | ||
249 | public void UpdateShape(ObjectShapePacket.ObjectDataBlock updatePacket) | ||
250 | { | ||
251 | this.primData.PathBegin = updatePacket.PathBegin; | ||
252 | this.primData.PathEnd = updatePacket.PathEnd; | ||
253 | this.primData.PathScaleX = updatePacket.PathScaleX; | ||
254 | this.primData.PathScaleY = updatePacket.PathScaleY; | ||
255 | this.primData.PathShearX = updatePacket.PathShearX; | ||
256 | this.primData.PathShearY = updatePacket.PathShearY; | ||
257 | this.primData.PathSkew = updatePacket.PathSkew; | ||
258 | this.primData.ProfileBegin = updatePacket.ProfileBegin; | ||
259 | this.primData.ProfileEnd = updatePacket.ProfileEnd; | ||
260 | this.primData.PathCurve = updatePacket.PathCurve; | ||
261 | this.primData.ProfileCurve = updatePacket.ProfileCurve; | ||
262 | this.primData.ProfileHollow = updatePacket.ProfileHollow; | ||
263 | this.primData.PathRadiusOffset = updatePacket.PathRadiusOffset; | ||
264 | this.primData.PathRevolutions = updatePacket.PathRevolutions; | ||
265 | this.primData.PathTaperX = updatePacket.PathTaperX; | ||
266 | this.primData.PathTaperY = updatePacket.PathTaperY; | ||
267 | this.primData.PathTwist = updatePacket.PathTwist; | ||
268 | this.primData.PathTwistBegin = updatePacket.PathTwistBegin; | ||
269 | } | ||
270 | |||
271 | /// <summary> | ||
272 | /// | ||
273 | /// </summary> | ||
274 | /// <param name="tex"></param> | ||
275 | public void UpdateTexture(byte[] tex) | ||
276 | { | ||
277 | this.primData.TextureEntry = tex; | ||
278 | } | ||
279 | |||
280 | /// <summary> | ||
281 | /// | ||
282 | /// </summary> | ||
283 | /// <param name="pack"></param> | ||
284 | public void UpdateObjectFlags(ObjectFlagUpdatePacket pack) | ||
285 | { | ||
286 | |||
287 | } | ||
288 | |||
289 | /// <summary> | ||
290 | /// | ||
291 | /// </summary> | ||
292 | /// <param name="prim"></param> | ||
293 | public void AssignToParent(Primitive prim) | ||
294 | { | ||
295 | |||
296 | } | ||
297 | |||
298 | #endregion | ||
299 | |||
300 | # region Inventory Methods | ||
301 | /// <summary> | ||
302 | /// | ||
303 | /// </summary> | ||
304 | /// <param name="item"></param> | ||
305 | /// <returns></returns> | ||
306 | public bool AddToInventory(InventoryItem item) | ||
307 | { | ||
308 | return false; | ||
309 | } | ||
310 | |||
311 | /// <summary> | ||
312 | /// | ||
313 | /// </summary> | ||
314 | /// <param name="itemID"></param> | ||
315 | /// <returns></returns> | ||
316 | public InventoryItem RemoveFromInventory(LLUUID itemID) | ||
317 | { | ||
318 | return null; | ||
319 | } | ||
320 | |||
321 | /// <summary> | ||
322 | /// | ||
323 | /// </summary> | ||
324 | /// <param name="simClient"></param> | ||
325 | /// <param name="packet"></param> | ||
326 | public void RequestInventoryInfo(IClientAPI simClient, RequestTaskInventoryPacket packet) | ||
327 | { | ||
328 | |||
329 | } | ||
330 | |||
331 | /// <summary> | ||
332 | /// | ||
333 | /// </summary> | ||
334 | /// <param name="simClient"></param> | ||
335 | /// <param name="xferID"></param> | ||
336 | public void RequestXferInventory(IClientAPI simClient, ulong xferID) | ||
337 | { | ||
338 | //will only currently work if the total size of the inventory data array is under about 1000 bytes | ||
339 | SendXferPacketPacket send = new SendXferPacketPacket(); | ||
340 | |||
341 | send.XferID.ID = xferID; | ||
342 | send.XferID.Packet = 1 + 2147483648; | ||
343 | send.DataPacket.Data = this.ConvertInventoryToBytes(); | ||
344 | |||
345 | simClient.OutPacket(send); | ||
346 | } | ||
347 | |||
348 | /// <summary> | ||
349 | /// | ||
350 | /// </summary> | ||
351 | /// <returns></returns> | ||
352 | public byte[] ConvertInventoryToBytes() | ||
353 | { | ||
354 | System.Text.Encoding enc = System.Text.Encoding.ASCII; | ||
355 | byte[] result = new byte[0]; | ||
356 | List<byte[]> inventoryData = new List<byte[]>(); | ||
357 | int totallength = 0; | ||
358 | foreach (InventoryItem invItem in inventoryItems.Values) | ||
359 | { | ||
360 | byte[] data = enc.GetBytes(invItem.ExportString()); | ||
361 | inventoryData.Add(data); | ||
362 | totallength += data.Length; | ||
363 | } | ||
364 | //TODO: copy arrays into the single result array | ||
365 | |||
366 | return result; | ||
367 | } | ||
368 | |||
369 | /// <summary> | ||
370 | /// | ||
371 | /// </summary> | ||
372 | /// <param name="data"></param> | ||
373 | public void CreateInventoryFromBytes(byte[] data) | ||
374 | { | ||
375 | |||
376 | } | ||
377 | |||
378 | #endregion | ||
379 | |||
380 | #region Update viewers Methods | ||
381 | |||
382 | /// <summary> | ||
383 | /// | ||
384 | /// </summary> | ||
385 | /// <param name="remoteClient"></param> | ||
386 | public void SendFullUpdateForAllChildren(IClientAPI remoteClient) | ||
387 | { | ||
388 | this.SendFullUpdateToClient(remoteClient); | ||
389 | for (int i = 0; i < this.children.Count; i++) | ||
390 | { | ||
391 | if (this.children[i] is Primitive) | ||
392 | { | ||
393 | ((Primitive)this.children[i]).SendFullUpdateForAllChildren(remoteClient); | ||
394 | } | ||
395 | } | ||
396 | } | ||
397 | |||
398 | /// <summary> | ||
399 | /// | ||
400 | /// </summary> | ||
401 | /// <param name="remoteClient"></param> | ||
402 | public void SendFullUpdateToClient(IClientAPI remoteClient) | ||
403 | { | ||
404 | LLVector3 lPos; | ||
405 | if (this._physActor != null && this.physicsEnabled) | ||
406 | { | ||
407 | PhysicsVector pPos = this._physActor.Position; | ||
408 | lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); | ||
409 | } | ||
410 | else | ||
411 | { | ||
412 | lPos = this.Pos; | ||
413 | } | ||
414 | |||
415 | remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.primData, lPos, new LLUUID("00000000-0000-0000-9999-000000000005"), this.flags); | ||
416 | } | ||
417 | |||
418 | /// <summary> | ||
419 | /// | ||
420 | /// </summary> | ||
421 | public void SendFullUpdateToAllClients() | ||
422 | { | ||
423 | List<ScenePresence> avatars = this.m_world.RequestAvatarList(); | ||
424 | for (int i = 0; i < avatars.Count; i++) | ||
425 | { | ||
426 | this.SendFullUpdateToClient(avatars[i].ControllingClient); | ||
427 | } | ||
428 | } | ||
429 | |||
430 | /// <summary> | ||
431 | /// | ||
432 | /// </summary> | ||
433 | /// <param name="RemoteClient"></param> | ||
434 | public void SendTerseUpdateToClient(IClientAPI RemoteClient) | ||
435 | { | ||
436 | LLVector3 lPos; | ||
437 | Axiom.MathLib.Quaternion lRot; | ||
438 | if (this._physActor != null && this.physicsEnabled) //is this needed ? doesn't the property fields do this for us? | ||
439 | { | ||
440 | PhysicsVector pPos = this._physActor.Position; | ||
441 | lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); | ||
442 | lRot = this._physActor.Orientation; | ||
443 | } | ||
444 | else | ||
445 | { | ||
446 | lPos = this.Pos; | ||
447 | lRot = this.rotation; | ||
448 | } | ||
449 | LLQuaternion mRot = new LLQuaternion(lRot.x, lRot.y, lRot.z, lRot.w); | ||
450 | RemoteClient.SendPrimTerseUpdate(this.m_regionHandle, 64096, this.LocalId, lPos, mRot); | ||
451 | } | ||
452 | |||
453 | /// <summary> | ||
454 | /// | ||
455 | /// </summary> | ||
456 | public void SendTerseUpdateToALLClients() | ||
457 | { | ||
458 | List<ScenePresence> avatars = this.m_world.RequestAvatarList(); | ||
459 | for (int i = 0; i < avatars.Count; i++) | ||
460 | { | ||
461 | this.SendTerseUpdateToClient(avatars[i].ControllingClient); | ||
462 | } | ||
463 | } | ||
464 | |||
465 | #endregion | ||
466 | |||
467 | #region Create Methods | ||
468 | |||
469 | /// <summary> | ||
470 | /// | ||
471 | /// </summary> | ||
472 | /// <param name="addPacket"></param> | ||
473 | /// <param name="ownerID"></param> | ||
474 | /// <param name="localID"></param> | ||
475 | public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID ownerID, uint localID) | ||
476 | { | ||
477 | PrimData PData = new PrimData(); | ||
478 | this.primData = PData; | ||
479 | this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | ||
480 | |||
481 | PData.OwnerID = ownerID; | ||
482 | PData.PCode = addPacket.ObjectData.PCode; | ||
483 | PData.PathBegin = addPacket.ObjectData.PathBegin; | ||
484 | PData.PathEnd = addPacket.ObjectData.PathEnd; | ||
485 | PData.PathScaleX = addPacket.ObjectData.PathScaleX; | ||
486 | PData.PathScaleY = addPacket.ObjectData.PathScaleY; | ||
487 | PData.PathShearX = addPacket.ObjectData.PathShearX; | ||
488 | PData.PathShearY = addPacket.ObjectData.PathShearY; | ||
489 | PData.PathSkew = addPacket.ObjectData.PathSkew; | ||
490 | PData.ProfileBegin = addPacket.ObjectData.ProfileBegin; | ||
491 | PData.ProfileEnd = addPacket.ObjectData.ProfileEnd; | ||
492 | PData.Scale = addPacket.ObjectData.Scale; | ||
493 | PData.PathCurve = addPacket.ObjectData.PathCurve; | ||
494 | PData.ProfileCurve = addPacket.ObjectData.ProfileCurve; | ||
495 | PData.ParentID = 0; | ||
496 | PData.ProfileHollow = addPacket.ObjectData.ProfileHollow; | ||
497 | PData.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset; | ||
498 | PData.PathRevolutions = addPacket.ObjectData.PathRevolutions; | ||
499 | PData.PathTaperX = addPacket.ObjectData.PathTaperX; | ||
500 | PData.PathTaperY = addPacket.ObjectData.PathTaperY; | ||
501 | PData.PathTwist = addPacket.ObjectData.PathTwist; | ||
502 | PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin; | ||
503 | LLVector3 pos1 = addPacket.ObjectData.RayEnd; | ||
504 | this.primData.FullID = this.uuid = LLUUID.Random(); | ||
505 | this.primData.LocalID = m_localId = (uint)(localID); | ||
506 | this.primData.Position = this.Pos = pos1; | ||
507 | |||
508 | this.updateFlag = 1; | ||
509 | } | ||
510 | |||
511 | /// <summary> | ||
512 | /// | ||
513 | /// </summary> | ||
514 | /// <param name="data"></param> | ||
515 | public void CreateFromBytes(byte[] data) | ||
516 | { | ||
517 | |||
518 | } | ||
519 | |||
520 | /// <summary> | ||
521 | /// | ||
522 | /// </summary> | ||
523 | /// <param name="primData"></param> | ||
524 | public void CreateFromPrimData(PrimData primData) | ||
525 | { | ||
526 | this.CreateFromPrimData(primData, primData.Position, primData.LocalID, false); | ||
527 | } | ||
528 | |||
529 | /// <summary> | ||
530 | /// | ||
531 | /// </summary> | ||
532 | /// <param name="primData"></param> | ||
533 | /// <param name="posi"></param> | ||
534 | /// <param name="localID"></param> | ||
535 | /// <param name="newprim"></param> | ||
536 | public void CreateFromPrimData(PrimData primData, LLVector3 posi, uint localID, bool newprim) | ||
537 | { | ||
538 | |||
539 | } | ||
540 | |||
541 | public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) | ||
542 | { | ||
543 | // Console.WriteLine("moving prim to new location " + pos.X + " , " + pos.Y + " , " + pos.Z); | ||
544 | this.Pos = pos; | ||
545 | this.SendTerseUpdateToALLClients(); | ||
546 | } | ||
547 | |||
548 | public void GetProperites(IClientAPI client) | ||
549 | { | ||
550 | //needs changing | ||
551 | ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); | ||
552 | proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; | ||
553 | proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); | ||
554 | proper.ObjectData[0].ItemID = LLUUID.Zero; | ||
555 | proper.ObjectData[0].CreationDate = (ulong)primData.CreationDate; | ||
556 | proper.ObjectData[0].CreatorID = primData.OwnerID; | ||
557 | proper.ObjectData[0].FolderID = LLUUID.Zero; | ||
558 | proper.ObjectData[0].FromTaskID = LLUUID.Zero; | ||
559 | proper.ObjectData[0].GroupID = LLUUID.Zero; | ||
560 | proper.ObjectData[0].InventorySerial = 0; | ||
561 | proper.ObjectData[0].LastOwnerID = LLUUID.Zero; | ||
562 | proper.ObjectData[0].ObjectID = this.uuid; | ||
563 | proper.ObjectData[0].OwnerID = primData.OwnerID; | ||
564 | proper.ObjectData[0].TouchName = new byte[0]; | ||
565 | proper.ObjectData[0].TextureID = new byte[0]; | ||
566 | proper.ObjectData[0].SitName = new byte[0]; | ||
567 | proper.ObjectData[0].Name = new byte[0]; | ||
568 | proper.ObjectData[0].Description = new byte[0]; | ||
569 | proper.ObjectData[0].OwnerMask = primData.OwnerMask; | ||
570 | proper.ObjectData[0].NextOwnerMask = primData.NextOwnerMask; | ||
571 | proper.ObjectData[0].GroupMask = primData.GroupMask; | ||
572 | proper.ObjectData[0].EveryoneMask = primData.EveryoneMask; | ||
573 | proper.ObjectData[0].BaseMask = primData.BaseMask; | ||
574 | |||
575 | client.OutPacket(proper); | ||
576 | |||
577 | } | ||
578 | |||
579 | #endregion | ||
580 | |||
581 | } | ||
582 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/Scene.PacketHandlers.cs b/OpenSim/OpenSim.Region/Scenes/Scene.PacketHandlers.cs deleted file mode 100644 index d1a2717..0000000 --- a/OpenSim/OpenSim.Region/Scenes/Scene.PacketHandlers.cs +++ /dev/null | |||
@@ -1,305 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.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.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using libsecondlife; | ||
32 | using libsecondlife.Packets; | ||
33 | using OpenSim.Physics.Manager; | ||
34 | using OpenSim.Framework.Interfaces; | ||
35 | using OpenSim.Framework.Types; | ||
36 | using OpenSim.Framework.Inventory; | ||
37 | using OpenSim.Framework.Utilities; | ||
38 | |||
39 | namespace OpenSim.Region.Scenes | ||
40 | { | ||
41 | public partial class Scene | ||
42 | { | ||
43 | /// <summary> | ||
44 | /// Modifies terrain using the specified information | ||
45 | /// </summary> | ||
46 | /// <param name="height">The height at which the user started modifying the terrain</param> | ||
47 | /// <param name="seconds">The number of seconds the modify button was pressed</param> | ||
48 | /// <param name="brushsize">The size of the brush used</param> | ||
49 | /// <param name="action">The action to be performed</param> | ||
50 | /// <param name="north">Distance from the north border where the cursor is located</param> | ||
51 | /// <param name="west">Distance from the west border where the cursor is located</param> | ||
52 | public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west) | ||
53 | { | ||
54 | // Shiny. | ||
55 | double size = (double)(1 << brushsize); | ||
56 | |||
57 | switch (action) | ||
58 | { | ||
59 | case 0: | ||
60 | // flatten terrain | ||
61 | Terrain.flatten(north, west, size, (double)seconds / 100.0); | ||
62 | RegenerateTerrain(true, (int)north, (int)west); | ||
63 | break; | ||
64 | case 1: | ||
65 | // raise terrain | ||
66 | Terrain.raise(north, west, size, (double)seconds / 100.0); | ||
67 | RegenerateTerrain(true, (int)north, (int)west); | ||
68 | break; | ||
69 | case 2: | ||
70 | //lower terrain | ||
71 | Terrain.lower(north, west, size, (double)seconds / 100.0); | ||
72 | RegenerateTerrain(true, (int)north, (int)west); | ||
73 | break; | ||
74 | case 3: | ||
75 | // smooth terrain | ||
76 | Terrain.smooth(north, west, size, (double)seconds / 100.0); | ||
77 | RegenerateTerrain(true, (int)north, (int)west); | ||
78 | break; | ||
79 | case 4: | ||
80 | // noise | ||
81 | Terrain.noise(north, west, size, (double)seconds / 100.0); | ||
82 | RegenerateTerrain(true, (int)north, (int)west); | ||
83 | break; | ||
84 | case 5: | ||
85 | // revert | ||
86 | Terrain.revert(north, west, size, (double)seconds / 100.0); | ||
87 | RegenerateTerrain(true, (int)north, (int)west); | ||
88 | break; | ||
89 | |||
90 | // CLIENT EXTENSIONS GO HERE | ||
91 | case 128: | ||
92 | // erode-thermal | ||
93 | break; | ||
94 | case 129: | ||
95 | // erode-aerobic | ||
96 | break; | ||
97 | case 130: | ||
98 | // erode-hydraulic | ||
99 | break; | ||
100 | } | ||
101 | return; | ||
102 | } | ||
103 | |||
104 | /// <summary> | ||
105 | /// | ||
106 | /// </summary> | ||
107 | /// <param name="message"></param> | ||
108 | /// <param name="type"></param> | ||
109 | /// <param name="fromPos"></param> | ||
110 | /// <param name="fromName"></param> | ||
111 | /// <param name="fromAgentID"></param> | ||
112 | public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) | ||
113 | { | ||
114 | Console.WriteLine("Chat message"); | ||
115 | ScenePresence avatar = null; | ||
116 | foreach (IClientAPI client in m_clientThreads.Values) | ||
117 | { | ||
118 | int dis = -1000; | ||
119 | if (this.Avatars.ContainsKey(client.AgentId)) | ||
120 | { | ||
121 | |||
122 | avatar = this.Avatars[client.AgentId]; | ||
123 | // int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y)); | ||
124 | dis= (int)avatar.Pos.GetDistanceTo(fromPos); | ||
125 | Console.WriteLine("found avatar at " +dis); | ||
126 | |||
127 | } | ||
128 | |||
129 | switch (type) | ||
130 | { | ||
131 | case 0: // Whisper | ||
132 | if ((dis < 10) && (dis > -10)) | ||
133 | { | ||
134 | //should change so the message is sent through the avatar rather than direct to the ClientView | ||
135 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); | ||
136 | } | ||
137 | break; | ||
138 | case 1: // Say | ||
139 | if ((dis < 30) && (dis > -30)) | ||
140 | { | ||
141 | Console.WriteLine("sending chat"); | ||
142 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); | ||
143 | } | ||
144 | break; | ||
145 | case 2: // Shout | ||
146 | if ((dis < 100) && (dis > -100)) | ||
147 | { | ||
148 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); | ||
149 | } | ||
150 | break; | ||
151 | |||
152 | case 0xff: // Broadcast | ||
153 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); | ||
154 | break; | ||
155 | } | ||
156 | |||
157 | } | ||
158 | } | ||
159 | |||
160 | /// <summary> | ||
161 | /// | ||
162 | /// </summary> | ||
163 | /// <param name="primAsset"></param> | ||
164 | /// <param name="pos"></param> | ||
165 | public void RezObject(AssetBase primAsset, LLVector3 pos) | ||
166 | { | ||
167 | |||
168 | } | ||
169 | |||
170 | /// <summary> | ||
171 | /// | ||
172 | /// </summary> | ||
173 | /// <param name="packet"></param> | ||
174 | /// <param name="simClient"></param> | ||
175 | public void DeRezObject(Packet packet, IClientAPI simClient) | ||
176 | { | ||
177 | |||
178 | } | ||
179 | |||
180 | /// <summary> | ||
181 | /// | ||
182 | /// </summary> | ||
183 | /// <param name="remoteClient"></param> | ||
184 | public void SendAvatarsToClient(IClientAPI remoteClient) | ||
185 | { | ||
186 | |||
187 | } | ||
188 | |||
189 | /// <summary> | ||
190 | /// | ||
191 | /// </summary> | ||
192 | /// <param name="parentPrim"></param> | ||
193 | /// <param name="childPrims"></param> | ||
194 | public void LinkObjects(uint parentPrim, List<uint> childPrims) | ||
195 | { | ||
196 | |||
197 | |||
198 | } | ||
199 | |||
200 | /// <summary> | ||
201 | /// | ||
202 | /// </summary> | ||
203 | /// <param name="primLocalID"></param> | ||
204 | /// <param name="shapeBlock"></param> | ||
205 | public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock) | ||
206 | { | ||
207 | |||
208 | } | ||
209 | |||
210 | /// <summary> | ||
211 | /// | ||
212 | /// </summary> | ||
213 | /// <param name="primLocalID"></param> | ||
214 | /// <param name="remoteClient"></param> | ||
215 | public void SelectPrim(uint primLocalID, IClientAPI remoteClient) | ||
216 | { | ||
217 | foreach (Entity ent in Entities.Values) | ||
218 | { | ||
219 | if (ent.LocalId == primLocalID) | ||
220 | { | ||
221 | ((OpenSim.Region.Scenes.Primitive)ent).GetProperites(remoteClient); | ||
222 | break; | ||
223 | } | ||
224 | } | ||
225 | } | ||
226 | |||
227 | public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) | ||
228 | { | ||
229 | if (this.Entities.ContainsKey(objectID)) | ||
230 | { | ||
231 | ((Primitive)this.Entities[objectID]).GrapMovement(offset, pos, remoteClient); | ||
232 | } | ||
233 | } | ||
234 | |||
235 | /// <summary> | ||
236 | /// | ||
237 | /// </summary> | ||
238 | /// <param name="localID"></param> | ||
239 | /// <param name="packet"></param> | ||
240 | /// <param name="remoteClient"></param> | ||
241 | public void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient) | ||
242 | { | ||
243 | |||
244 | } | ||
245 | |||
246 | /// <summary> | ||
247 | /// | ||
248 | /// </summary> | ||
249 | /// <param name="localID"></param> | ||
250 | /// <param name="texture"></param> | ||
251 | /// <param name="remoteClient"></param> | ||
252 | public void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient) | ||
253 | { | ||
254 | |||
255 | } | ||
256 | |||
257 | /// <summary> | ||
258 | /// | ||
259 | /// </summary> | ||
260 | /// <param name="localID"></param> | ||
261 | /// <param name="pos"></param> | ||
262 | /// <param name="remoteClient"></param> | ||
263 | public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient) | ||
264 | { | ||
265 | foreach (Entity ent in Entities.Values) | ||
266 | { | ||
267 | if (ent.LocalId == localID) | ||
268 | { | ||
269 | ((OpenSim.Region.Scenes.Primitive)ent).UpdatePosition(pos); | ||
270 | break; | ||
271 | } | ||
272 | } | ||
273 | } | ||
274 | |||
275 | /// <summary> | ||
276 | /// | ||
277 | /// </summary> | ||
278 | /// <param name="localID"></param> | ||
279 | /// <param name="rot"></param> | ||
280 | /// <param name="remoteClient"></param> | ||
281 | public void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) | ||
282 | { | ||
283 | |||
284 | } | ||
285 | |||
286 | /// <summary> | ||
287 | /// | ||
288 | /// </summary> | ||
289 | /// <param name="localID"></param> | ||
290 | /// <param name="scale"></param> | ||
291 | /// <param name="remoteClient"></param> | ||
292 | public void UpdatePrimScale(uint localID, LLVector3 scale, IClientAPI remoteClient) | ||
293 | { | ||
294 | } | ||
295 | |||
296 | /// <summary> | ||
297 | /// Sends prims to a client | ||
298 | /// </summary> | ||
299 | /// <param name="RemoteClient">Client to send to</param> | ||
300 | public void GetInitialPrims(IClientAPI RemoteClient) | ||
301 | { | ||
302 | |||
303 | } | ||
304 | } | ||
305 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/Scene.Scripting.cs b/OpenSim/OpenSim.Region/Scenes/Scene.Scripting.cs deleted file mode 100644 index 7b53388..0000000 --- a/OpenSim/OpenSim.Region/Scenes/Scene.Scripting.cs +++ /dev/null | |||
@@ -1,184 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.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.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using System.IO; | ||
32 | using System.Reflection; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Interfaces; | ||
35 | using OpenSim.Framework.Types; | ||
36 | using libsecondlife; | ||
37 | |||
38 | namespace OpenSim.Region.Scenes | ||
39 | { | ||
40 | public partial class Scene | ||
41 | { | ||
42 | private Dictionary<string, IScriptEngine> scriptEngines = new Dictionary<string, IScriptEngine>(); | ||
43 | |||
44 | /// <summary> | ||
45 | /// | ||
46 | /// </summary> | ||
47 | private void LoadScriptEngines() | ||
48 | { | ||
49 | this.LoadScriptPlugins(); | ||
50 | } | ||
51 | |||
52 | /// <summary> | ||
53 | /// | ||
54 | /// </summary> | ||
55 | public void LoadScriptPlugins() | ||
56 | { | ||
57 | string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "ScriptEngines"); | ||
58 | string[] pluginFiles = Directory.GetFiles(path, "*.dll"); | ||
59 | |||
60 | |||
61 | for (int i = 0; i < pluginFiles.Length; i++) | ||
62 | { | ||
63 | this.AddPlugin(pluginFiles[i]); | ||
64 | } | ||
65 | } | ||
66 | |||
67 | /// <summary> | ||
68 | /// | ||
69 | /// </summary> | ||
70 | /// <param name="FileName"></param> | ||
71 | private void AddPlugin(string FileName) | ||
72 | { | ||
73 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); | ||
74 | |||
75 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
76 | { | ||
77 | if (pluginType.IsPublic) | ||
78 | { | ||
79 | if (!pluginType.IsAbstract) | ||
80 | { | ||
81 | Type typeInterface = pluginType.GetInterface("IScriptEngine", true); | ||
82 | |||
83 | if (typeInterface != null) | ||
84 | { | ||
85 | IScriptEngine plug = (IScriptEngine)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
86 | plug.Init(this); | ||
87 | this.scriptEngines.Add(plug.GetName(), plug); | ||
88 | |||
89 | } | ||
90 | |||
91 | typeInterface = null; | ||
92 | } | ||
93 | } | ||
94 | } | ||
95 | |||
96 | pluginAssembly = null; | ||
97 | } | ||
98 | |||
99 | /// <summary> | ||
100 | /// | ||
101 | /// </summary> | ||
102 | /// <param name="scriptType"></param> | ||
103 | /// <param name="scriptName"></param> | ||
104 | /// <param name="script"></param> | ||
105 | /// <param name="ent"></param> | ||
106 | public void LoadScript(string scriptType, string scriptName, string script, Entity ent) | ||
107 | { | ||
108 | if(this.scriptEngines.ContainsKey(scriptType)) | ||
109 | { | ||
110 | this.scriptEngines[scriptType].LoadScript(script, scriptName, ent.LocalId); | ||
111 | } | ||
112 | } | ||
113 | |||
114 | #region IScriptAPI Methods | ||
115 | |||
116 | /// <summary> | ||
117 | /// | ||
118 | /// </summary> | ||
119 | /// <param name="localID"></param> | ||
120 | /// <returns></returns> | ||
121 | public LLVector3 GetEntityPosition(uint localID) | ||
122 | { | ||
123 | LLVector3 res = new LLVector3(); | ||
124 | // Console.WriteLine("script- getting entity " + localID + " position"); | ||
125 | foreach (Entity entity in this.Entities.Values) | ||
126 | { | ||
127 | if (entity.LocalId == localID) | ||
128 | { | ||
129 | res.X = entity.Pos.X; | ||
130 | res.Y = entity.Pos.Y; | ||
131 | res.Z = entity.Pos.Z; | ||
132 | } | ||
133 | } | ||
134 | return res; | ||
135 | } | ||
136 | |||
137 | /// <summary> | ||
138 | /// | ||
139 | /// </summary> | ||
140 | /// <param name="localID"></param> | ||
141 | /// <param name="x"></param> | ||
142 | /// <param name="y"></param> | ||
143 | /// <param name="z"></param> | ||
144 | public void SetEntityPosition(uint localID, float x , float y, float z) | ||
145 | { | ||
146 | foreach (Entity entity in this.Entities.Values) | ||
147 | { | ||
148 | if (entity.LocalId == localID && entity is Primitive) | ||
149 | { | ||
150 | LLVector3 pos = entity.Pos; | ||
151 | pos.X = x; | ||
152 | pos.Y = y; | ||
153 | Primitive prim = entity as Primitive; | ||
154 | // Of course, we really should have asked the physEngine if this is possible, and if not, returned false. | ||
155 | //prim.UpdatePosition(pos); | ||
156 | // Console.WriteLine("script- setting entity " + localID + " positon"); | ||
157 | } | ||
158 | } | ||
159 | |||
160 | } | ||
161 | |||
162 | /// <summary> | ||
163 | /// | ||
164 | /// </summary> | ||
165 | /// <returns></returns> | ||
166 | public uint GetRandomAvatarID() | ||
167 | { | ||
168 | //Console.WriteLine("script- getting random avatar id"); | ||
169 | uint res = 0; | ||
170 | foreach (Entity entity in this.Entities.Values) | ||
171 | { | ||
172 | if (entity is ScenePresence) | ||
173 | { | ||
174 | res = entity.LocalId; | ||
175 | } | ||
176 | } | ||
177 | return res; | ||
178 | } | ||
179 | |||
180 | #endregion | ||
181 | |||
182 | |||
183 | } | ||
184 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/Scene.cs b/OpenSim/OpenSim.Region/Scenes/Scene.cs deleted file mode 100644 index f7d90fa..0000000 --- a/OpenSim/OpenSim.Region/Scenes/Scene.cs +++ /dev/null | |||
@@ -1,781 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.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 libsecondlife; | ||
30 | using libsecondlife.Packets; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Text; | ||
33 | using System.Reflection; | ||
34 | using System.IO; | ||
35 | using System.Threading; | ||
36 | using System.Timers; | ||
37 | using OpenSim.Physics.Manager; | ||
38 | using OpenSim.Framework.Interfaces; | ||
39 | using OpenSim.Framework.Types; | ||
40 | using OpenSim.Framework.Inventory; | ||
41 | using OpenSim.Framework; | ||
42 | using OpenSim.Terrain; | ||
43 | using OpenGrid.Framework.Communications; | ||
44 | using OpenSim.Caches; | ||
45 | using OpenSim.Region; | ||
46 | using OpenSim.Servers; | ||
47 | using OpenSim.Scripting; | ||
48 | |||
49 | namespace OpenSim.Region.Scenes | ||
50 | { | ||
51 | public delegate bool FilterAvatarList(ScenePresence avatar); | ||
52 | |||
53 | public partial class Scene : SceneBase, ILocalStorageReceiver, IScriptAPI | ||
54 | { | ||
55 | protected System.Timers.Timer m_heartbeatTimer = new System.Timers.Timer(); | ||
56 | protected Dictionary<libsecondlife.LLUUID, ScenePresence> Avatars; | ||
57 | protected Dictionary<libsecondlife.LLUUID, Primitive> Prims; | ||
58 | private PhysicsScene phyScene; | ||
59 | private float timeStep = 0.1f; | ||
60 | private Random Rand = new Random(); | ||
61 | private uint _primCount = 702000; | ||
62 | private int storageCount; | ||
63 | private Mutex updateLock; | ||
64 | |||
65 | protected AuthenticateSessionsBase authenticateHandler; | ||
66 | protected RegionCommsListener regionCommsHost; | ||
67 | protected CommunicationsManager commsManager; | ||
68 | |||
69 | protected Dictionary<LLUUID, Caps> capsHandlers = new Dictionary<LLUUID, Caps>(); | ||
70 | protected BaseHttpServer httpListener; | ||
71 | |||
72 | public ParcelManager parcelManager; | ||
73 | public EstateManager estateManager; | ||
74 | public EventManager eventManager; | ||
75 | public ScriptManager scriptManager; | ||
76 | |||
77 | #region Properties | ||
78 | /// <summary> | ||
79 | /// | ||
80 | /// </summary> | ||
81 | public PhysicsScene PhysScene | ||
82 | { | ||
83 | set | ||
84 | { | ||
85 | this.phyScene = value; | ||
86 | } | ||
87 | get | ||
88 | { | ||
89 | return (this.phyScene); | ||
90 | } | ||
91 | } | ||
92 | |||
93 | #endregion | ||
94 | |||
95 | #region Constructors | ||
96 | /// <summary> | ||
97 | /// Creates a new World class, and a region to go with it. | ||
98 | /// </summary> | ||
99 | /// <param name="clientThreads">Dictionary to contain client threads</param> | ||
100 | /// <param name="regionHandle">Region Handle for this region</param> | ||
101 | /// <param name="regionName">Region Name for this region</param> | ||
102 | public Scene(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer) | ||
103 | { | ||
104 | try | ||
105 | { | ||
106 | updateLock = new Mutex(false); | ||
107 | this.authenticateHandler = authen; | ||
108 | this.commsManager = commsMan; | ||
109 | this.assetCache = assetCach; | ||
110 | m_clientThreads = clientThreads; | ||
111 | m_regInfo = regInfo; | ||
112 | m_regionHandle = m_regInfo.RegionHandle; | ||
113 | m_regionName = m_regInfo.RegionName; | ||
114 | this.m_datastore = m_regInfo.DataStore; | ||
115 | this.RegisterRegionWithComms(); | ||
116 | |||
117 | parcelManager = new ParcelManager(this, this.m_regInfo); | ||
118 | estateManager = new EstateManager(this, this.m_regInfo); | ||
119 | scriptManager = new ScriptManager(this); | ||
120 | eventManager = new EventManager(); | ||
121 | |||
122 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs - creating new entitities instance"); | ||
123 | Entities = new Dictionary<libsecondlife.LLUUID, Entity>(); | ||
124 | Avatars = new Dictionary<LLUUID, ScenePresence>(); | ||
125 | Prims = new Dictionary<LLUUID, Primitive>(); | ||
126 | |||
127 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs - creating LandMap"); | ||
128 | Terrain = new TerrainEngine(); | ||
129 | |||
130 | ScenePresence.LoadAnims(); | ||
131 | this.httpListener = httpServer; | ||
132 | |||
133 | } | ||
134 | catch (Exception e) | ||
135 | { | ||
136 | OpenSim.Framework.Console.MainLog.Instance.Error( "World.cs: Constructor failed with exception " + e.ToString()); | ||
137 | } | ||
138 | } | ||
139 | #endregion | ||
140 | |||
141 | /// <summary> | ||
142 | /// | ||
143 | /// </summary> | ||
144 | public void StartTimer() | ||
145 | { | ||
146 | m_heartbeatTimer.Enabled = true; | ||
147 | m_heartbeatTimer.Interval = 100; | ||
148 | m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat); | ||
149 | } | ||
150 | |||
151 | |||
152 | #region Update Methods | ||
153 | |||
154 | |||
155 | /// <summary> | ||
156 | /// Performs per-frame updates regularly | ||
157 | /// </summary> | ||
158 | /// <param name="sender"></param> | ||
159 | /// <param name="e"></param> | ||
160 | void Heartbeat(object sender, System.EventArgs e) | ||
161 | { | ||
162 | this.Update(); | ||
163 | } | ||
164 | |||
165 | /// <summary> | ||
166 | /// Performs per-frame updates on the world, this should be the central world loop | ||
167 | /// </summary> | ||
168 | public override void Update() | ||
169 | { | ||
170 | updateLock.WaitOne(); | ||
171 | try | ||
172 | { | ||
173 | if (this.phyScene.IsThreaded) | ||
174 | { | ||
175 | this.phyScene.GetResults(); | ||
176 | |||
177 | } | ||
178 | |||
179 | foreach (libsecondlife.LLUUID UUID in Entities.Keys) | ||
180 | { | ||
181 | Entities[UUID].updateMovement(); | ||
182 | } | ||
183 | |||
184 | lock (this.m_syncRoot) | ||
185 | { | ||
186 | this.phyScene.Simulate(timeStep); | ||
187 | } | ||
188 | |||
189 | foreach (libsecondlife.LLUUID UUID in Entities.Keys) | ||
190 | { | ||
191 | Entities[UUID].update(); | ||
192 | } | ||
193 | |||
194 | // General purpose event manager | ||
195 | eventManager.TriggerOnFrame(); | ||
196 | |||
197 | //backup world data | ||
198 | this.storageCount++; | ||
199 | if (storageCount > 1200) //set to how often you want to backup | ||
200 | { | ||
201 | this.Backup(); | ||
202 | storageCount = 0; | ||
203 | } | ||
204 | } | ||
205 | catch (Exception e) | ||
206 | { | ||
207 | OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: Update() - Failed with exception " + e.ToString()); | ||
208 | } | ||
209 | updateLock.ReleaseMutex(); | ||
210 | |||
211 | } | ||
212 | |||
213 | /// <summary> | ||
214 | /// | ||
215 | /// </summary> | ||
216 | /// <returns></returns> | ||
217 | public bool Backup() | ||
218 | { | ||
219 | /* | ||
220 | try | ||
221 | { | ||
222 | // Terrain backup routines | ||
223 | if (Terrain.tainted > 0) | ||
224 | { | ||
225 | Terrain.tainted = 0; | ||
226 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs: Backup() - Terrain tainted, saving."); | ||
227 | localStorage.SaveMap(Terrain.getHeights1D()); | ||
228 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs: Backup() - Terrain saved, informing Physics."); | ||
229 | lock (this.m_syncRoot) | ||
230 | { | ||
231 | phyScene.SetTerrain(Terrain.getHeights1D()); | ||
232 | } | ||
233 | } | ||
234 | |||
235 | // Primitive backup routines | ||
236 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs: Backup() - Backing up Primitives"); | ||
237 | foreach (libsecondlife.LLUUID UUID in Entities.Keys) | ||
238 | { | ||
239 | Entities[UUID].BackUp(); | ||
240 | } | ||
241 | |||
242 | //Parcel backup routines | ||
243 | ParcelData[] parcels = new ParcelData[parcelManager.parcelList.Count]; | ||
244 | int i = 0; | ||
245 | foreach (OpenSim.Region.Parcel parcel in parcelManager.parcelList.Values) | ||
246 | { | ||
247 | parcels[i] = parcel.parcelData; | ||
248 | i++; | ||
249 | } | ||
250 | localStorage.SaveParcels(parcels); | ||
251 | |||
252 | // Backup successful | ||
253 | return true; | ||
254 | } | ||
255 | catch (Exception e) | ||
256 | { | ||
257 | // Backup failed | ||
258 | OpenSim.Framework.Console.MainLog.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "World.cs: Backup() - Backup Failed with exception " + e.ToString()); | ||
259 | return false; | ||
260 | } | ||
261 | */ | ||
262 | return true; | ||
263 | } | ||
264 | #endregion | ||
265 | |||
266 | #region Regenerate Terrain | ||
267 | |||
268 | /// <summary> | ||
269 | /// Rebuilds the terrain using a procedural algorithm | ||
270 | /// </summary> | ||
271 | public void RegenerateTerrain() | ||
272 | { | ||
273 | try | ||
274 | { | ||
275 | Terrain.hills(); | ||
276 | |||
277 | lock (this.m_syncRoot) | ||
278 | { | ||
279 | this.phyScene.SetTerrain(Terrain.getHeights1D()); | ||
280 | } | ||
281 | this.localStorage.SaveMap(this.Terrain.getHeights1D()); | ||
282 | |||
283 | foreach (IClientAPI client in m_clientThreads.Values) | ||
284 | { | ||
285 | this.SendLayerData(client); | ||
286 | } | ||
287 | |||
288 | foreach (libsecondlife.LLUUID UUID in Entities.Keys) | ||
289 | { | ||
290 | Entities[UUID].LandRenegerated(); | ||
291 | } | ||
292 | } | ||
293 | catch (Exception e) | ||
294 | { | ||
295 | OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString()); | ||
296 | } | ||
297 | } | ||
298 | |||
299 | /// <summary> | ||
300 | /// Rebuilds the terrain using a 2D float array | ||
301 | /// </summary> | ||
302 | /// <param name="newMap">256,256 float array containing heights</param> | ||
303 | public void RegenerateTerrain(float[,] newMap) | ||
304 | { | ||
305 | try | ||
306 | { | ||
307 | this.Terrain.setHeights2D(newMap); | ||
308 | lock (this.m_syncRoot) | ||
309 | { | ||
310 | this.phyScene.SetTerrain(this.Terrain.getHeights1D()); | ||
311 | } | ||
312 | this.localStorage.SaveMap(this.Terrain.getHeights1D()); | ||
313 | |||
314 | foreach (IClientAPI client in m_clientThreads.Values) | ||
315 | { | ||
316 | this.SendLayerData(client); | ||
317 | } | ||
318 | |||
319 | foreach (libsecondlife.LLUUID UUID in Entities.Keys) | ||
320 | { | ||
321 | Entities[UUID].LandRenegerated(); | ||
322 | } | ||
323 | } | ||
324 | catch (Exception e) | ||
325 | { | ||
326 | OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString()); | ||
327 | } | ||
328 | } | ||
329 | |||
330 | /// <summary> | ||
331 | /// Rebuilds the terrain assuming changes occured at a specified point[?] | ||
332 | /// </summary> | ||
333 | /// <param name="changes">???</param> | ||
334 | /// <param name="pointx">???</param> | ||
335 | /// <param name="pointy">???</param> | ||
336 | public void RegenerateTerrain(bool changes, int pointx, int pointy) | ||
337 | { | ||
338 | try | ||
339 | { | ||
340 | if (changes) | ||
341 | { | ||
342 | /* Dont save here, rely on tainting system instead */ | ||
343 | |||
344 | foreach (IClientAPI client in m_clientThreads.Values) | ||
345 | { | ||
346 | this.SendLayerData(pointx, pointy, client); | ||
347 | } | ||
348 | } | ||
349 | } | ||
350 | catch (Exception e) | ||
351 | { | ||
352 | OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString()); | ||
353 | } | ||
354 | } | ||
355 | |||
356 | #endregion | ||
357 | |||
358 | #region Load Terrain | ||
359 | /// <summary> | ||
360 | /// Loads the World heightmap | ||
361 | /// </summary> | ||
362 | /// | ||
363 | public override void LoadWorldMap() | ||
364 | { | ||
365 | try | ||
366 | { | ||
367 | float[] map = this.localStorage.LoadWorld(); | ||
368 | if (map == null) | ||
369 | { | ||
370 | if (string.IsNullOrEmpty(this.m_regInfo.estateSettings.terrainFile)) | ||
371 | { | ||
372 | Console.WriteLine("No default terrain, procedurally generating..."); | ||
373 | this.Terrain.hills(); | ||
374 | |||
375 | this.localStorage.SaveMap(this.Terrain.getHeights1D()); | ||
376 | } | ||
377 | else | ||
378 | { | ||
379 | try | ||
380 | { | ||
381 | this.Terrain.loadFromFileF32(this.m_regInfo.estateSettings.terrainFile); | ||
382 | this.Terrain *= this.m_regInfo.estateSettings.terrainMultiplier; | ||
383 | } | ||
384 | catch | ||
385 | { | ||
386 | Console.WriteLine("Unable to load default terrain, procedurally generating instead..."); | ||
387 | Terrain.hills(); | ||
388 | } | ||
389 | this.localStorage.SaveMap(this.Terrain.getHeights1D()); | ||
390 | } | ||
391 | } | ||
392 | else | ||
393 | { | ||
394 | this.Terrain.setHeights1D(map); | ||
395 | } | ||
396 | |||
397 | CreateTerrainTexture(); | ||
398 | |||
399 | } | ||
400 | catch (Exception e) | ||
401 | { | ||
402 | OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: LoadWorldMap() - Failed with exception " + e.ToString()); | ||
403 | } | ||
404 | } | ||
405 | |||
406 | /// <summary> | ||
407 | /// | ||
408 | /// </summary> | ||
409 | private void CreateTerrainTexture() | ||
410 | { | ||
411 | //create a texture asset of the terrain | ||
412 | byte[] data = this.Terrain.exportJpegImage("defaultstripe.png"); | ||
413 | this.m_regInfo.estateSettings.terrainImageID = LLUUID.Random(); | ||
414 | AssetBase asset = new AssetBase(); | ||
415 | asset.FullID = this.m_regInfo.estateSettings.terrainImageID; | ||
416 | asset.Data = data; | ||
417 | asset.Name = "terrainImage"; | ||
418 | asset.Type = 0; | ||
419 | this.assetCache.AddAsset(asset); | ||
420 | } | ||
421 | #endregion | ||
422 | |||
423 | #region Primitives Methods | ||
424 | |||
425 | |||
426 | /// <summary> | ||
427 | /// Loads the World's objects | ||
428 | /// </summary> | ||
429 | public void LoadPrimsFromStorage() | ||
430 | { | ||
431 | try | ||
432 | { | ||
433 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs: LoadPrimsFromStorage() - Loading primitives"); | ||
434 | this.localStorage.LoadPrimitives(this); | ||
435 | } | ||
436 | catch (Exception e) | ||
437 | { | ||
438 | OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: LoadPrimsFromStorage() - Failed with exception " + e.ToString()); | ||
439 | } | ||
440 | } | ||
441 | |||
442 | /// <summary> | ||
443 | /// Loads a specific object from storage | ||
444 | /// </summary> | ||
445 | /// <param name="prim">The object to load</param> | ||
446 | public void PrimFromStorage(PrimData prim) | ||
447 | { | ||
448 | |||
449 | } | ||
450 | |||
451 | /// <summary> | ||
452 | /// | ||
453 | /// </summary> | ||
454 | /// <param name="addPacket"></param> | ||
455 | /// <param name="agentClient"></param> | ||
456 | public void AddNewPrim(Packet addPacket, IClientAPI agentClient) | ||
457 | { | ||
458 | AddNewPrim((ObjectAddPacket)addPacket, agentClient.AgentId); | ||
459 | } | ||
460 | |||
461 | /// <summary> | ||
462 | /// | ||
463 | /// </summary> | ||
464 | /// <param name="addPacket"></param> | ||
465 | /// <param name="ownerID"></param> | ||
466 | public void AddNewPrim(ObjectAddPacket addPacket, LLUUID ownerID) | ||
467 | { | ||
468 | try | ||
469 | { | ||
470 | Primitive prim = new Primitive(m_regionHandle, this, addPacket, ownerID, this._primCount); | ||
471 | |||
472 | this.Entities.Add(prim.uuid, prim); | ||
473 | this._primCount++; | ||
474 | |||
475 | // Trigger event for listeners | ||
476 | eventManager.TriggerOnNewPrimitive(prim); | ||
477 | } | ||
478 | catch (Exception e) | ||
479 | { | ||
480 | OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: AddNewPrim() - Failed with exception " + e.ToString()); | ||
481 | } | ||
482 | } | ||
483 | |||
484 | #endregion | ||
485 | |||
486 | #region Add/Remove Avatar Methods | ||
487 | |||
488 | /// <summary> | ||
489 | /// | ||
490 | /// </summary> | ||
491 | /// <param name="remoteClient"></param | ||
492 | /// <param name="agentID"></param> | ||
493 | /// <param name="child"></param> | ||
494 | public override void AddNewClient(IClientAPI remoteClient, LLUUID agentID, bool child) | ||
495 | { | ||
496 | remoteClient.OnRegionHandShakeReply += this.SendLayerData; | ||
497 | //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims); | ||
498 | remoteClient.OnChatFromViewer += this.SimChat; | ||
499 | remoteClient.OnRequestWearables += this.InformClientOfNeighbours; | ||
500 | remoteClient.OnAddPrim += this.AddNewPrim; | ||
501 | remoteClient.OnUpdatePrimPosition += this.UpdatePrimPosition; | ||
502 | remoteClient.OnRequestMapBlocks += this.RequestMapBlocks; | ||
503 | remoteClient.OnTeleportLocationRequest += this.RequestTeleportLocation; | ||
504 | //remoteClient.OnObjectSelect += this.SelectPrim; | ||
505 | remoteClient.OnGrapUpdate += this.MoveObject; | ||
506 | |||
507 | /* remoteClient.OnParcelPropertiesRequest += new ParcelPropertiesRequest(parcelManager.handleParcelPropertiesRequest); | ||
508 | remoteClient.OnParcelDivideRequest += new ParcelDivideRequest(parcelManager.handleParcelDivideRequest); | ||
509 | remoteClient.OnParcelJoinRequest += new ParcelJoinRequest(parcelManager.handleParcelJoinRequest); | ||
510 | remoteClient.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(parcelManager.handleParcelPropertiesUpdateRequest); | ||
511 | remoteClient.OnEstateOwnerMessage += new EstateOwnerMessageRequest(estateManager.handleEstateOwnerMessage); | ||
512 | */ | ||
513 | |||
514 | ScenePresence newAvatar = null; | ||
515 | try | ||
516 | { | ||
517 | |||
518 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); | ||
519 | newAvatar = new ScenePresence(remoteClient, this, this.m_regInfo); | ||
520 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs:AddViewerAgent() - Adding new avatar to world"); | ||
521 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs:AddViewerAgent() - Starting RegionHandshake "); | ||
522 | |||
523 | //newAvatar.SendRegionHandshake(); | ||
524 | this.estateManager.sendRegionHandshake(remoteClient); | ||
525 | |||
526 | PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z); | ||
527 | lock (this.m_syncRoot) | ||
528 | { | ||
529 | newAvatar.PhysActor = this.phyScene.AddAvatar(pVec); | ||
530 | } | ||
531 | |||
532 | lock (Entities) | ||
533 | { | ||
534 | if (!Entities.ContainsKey(agentID)) | ||
535 | { | ||
536 | this.Entities.Add(agentID, newAvatar); | ||
537 | } | ||
538 | else | ||
539 | { | ||
540 | Entities[agentID] = newAvatar; | ||
541 | } | ||
542 | } | ||
543 | lock (Avatars) | ||
544 | { | ||
545 | if (Avatars.ContainsKey(agentID)) | ||
546 | { | ||
547 | Avatars[agentID] = newAvatar; | ||
548 | } | ||
549 | else | ||
550 | { | ||
551 | this.Avatars.Add(agentID, newAvatar); | ||
552 | } | ||
553 | } | ||
554 | } | ||
555 | catch (Exception e) | ||
556 | { | ||
557 | OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: AddViewerAgent() - Failed with exception " + e.ToString()); | ||
558 | } | ||
559 | return; | ||
560 | } | ||
561 | |||
562 | |||
563 | |||
564 | /// <summary> | ||
565 | /// | ||
566 | /// </summary> | ||
567 | /// <param name="agentID"></param> | ||
568 | public override void RemoveClient(LLUUID agentID) | ||
569 | { | ||
570 | eventManager.TriggerOnRemovePresence(agentID); | ||
571 | |||
572 | return; | ||
573 | } | ||
574 | #endregion | ||
575 | |||
576 | #region Request Avatars List Methods | ||
577 | //The idea is to have a group of method that return a list of avatars meeting some requirement | ||
578 | // ie it could be all Avatars within a certain range of the calling prim/avatar. | ||
579 | |||
580 | /// <summary> | ||
581 | /// Request a List of all Avatars in this World | ||
582 | /// </summary> | ||
583 | /// <returns></returns> | ||
584 | public List<ScenePresence> RequestAvatarList() | ||
585 | { | ||
586 | List<ScenePresence> result = new List<ScenePresence>(); | ||
587 | |||
588 | foreach (ScenePresence avatar in Avatars.Values) | ||
589 | { | ||
590 | result.Add(avatar); | ||
591 | } | ||
592 | |||
593 | return result; | ||
594 | } | ||
595 | |||
596 | /// <summary> | ||
597 | /// Request a filtered list of Avatars in this World | ||
598 | /// </summary> | ||
599 | /// <returns></returns> | ||
600 | public List<ScenePresence> RequestAvatarList(FilterAvatarList filter) | ||
601 | { | ||
602 | List<ScenePresence> result = new List<ScenePresence>(); | ||
603 | |||
604 | foreach (ScenePresence avatar in Avatars.Values) | ||
605 | { | ||
606 | if (filter(avatar)) | ||
607 | { | ||
608 | result.Add(avatar); | ||
609 | } | ||
610 | } | ||
611 | |||
612 | return result; | ||
613 | } | ||
614 | |||
615 | /// <summary> | ||
616 | /// Request a Avatar by UUID | ||
617 | /// </summary> | ||
618 | /// <param name="avatarID"></param> | ||
619 | /// <returns></returns> | ||
620 | public ScenePresence RequestAvatar(LLUUID avatarID) | ||
621 | { | ||
622 | if (this.Avatars.ContainsKey(avatarID)) | ||
623 | { | ||
624 | return Avatars[avatarID]; | ||
625 | } | ||
626 | return null; | ||
627 | } | ||
628 | #endregion | ||
629 | |||
630 | |||
631 | #region RegionCommsHost | ||
632 | |||
633 | /// <summary> | ||
634 | /// | ||
635 | /// </summary> | ||
636 | public void RegisterRegionWithComms() | ||
637 | { | ||
638 | GridInfo gridSettings = new GridInfo(); | ||
639 | this.regionCommsHost = this.commsManager.GridServer.RegisterRegion(this.m_regInfo,gridSettings); | ||
640 | if (this.regionCommsHost != null) | ||
641 | { | ||
642 | this.regionCommsHost.OnExpectUser += new ExpectUserDelegate(this.NewUserConnection); | ||
643 | this.regionCommsHost.OnAvatarCrossingIntoRegion += new AgentCrossing(this.AgentCrossing); | ||
644 | } | ||
645 | } | ||
646 | |||
647 | /// <summary> | ||
648 | /// | ||
649 | /// </summary> | ||
650 | /// <param name="regionHandle"></param> | ||
651 | /// <param name="agent"></param> | ||
652 | public void NewUserConnection(ulong regionHandle, AgentCircuitData agent) | ||
653 | { | ||
654 | // Console.WriteLine("World.cs - add new user connection"); | ||
655 | //should just check that its meant for this region | ||
656 | if (regionHandle == this.m_regInfo.RegionHandle) | ||
657 | { | ||
658 | if (agent.CapsPath != "") | ||
659 | { | ||
660 | //Console.WriteLine("new user, so creating caps handler for it"); | ||
661 | Caps cap = new Caps(this.assetCache, httpListener, this.m_regInfo.CommsIPListenAddr, 9000, agent.CapsPath, agent.AgentID); | ||
662 | cap.RegisterHandlers(); | ||
663 | this.capsHandlers.Add(agent.AgentID, cap); | ||
664 | } | ||
665 | this.authenticateHandler.AddNewCircuit(agent.circuitcode, agent); | ||
666 | } | ||
667 | } | ||
668 | |||
669 | public void AgentCrossing(ulong regionHandle, libsecondlife.LLUUID agentID, libsecondlife.LLVector3 position) | ||
670 | { | ||
671 | if (regionHandle == this.m_regInfo.RegionHandle) | ||
672 | { | ||
673 | if (this.Avatars.ContainsKey(agentID)) | ||
674 | { | ||
675 | this.Avatars[agentID].MakeAvatar(position); | ||
676 | } | ||
677 | } | ||
678 | } | ||
679 | |||
680 | /// <summary> | ||
681 | /// | ||
682 | /// </summary> | ||
683 | public void InformClientOfNeighbours(IClientAPI remoteClient) | ||
684 | { | ||
685 | // Console.WriteLine("informing client of neighbouring regions"); | ||
686 | List<RegionInfo> neighbours = this.commsManager.GridServer.RequestNeighbours(this.m_regInfo); | ||
687 | |||
688 | //Console.WriteLine("we have " + neighbours.Count + " neighbouring regions"); | ||
689 | if (neighbours != null) | ||
690 | { | ||
691 | for (int i = 0; i < neighbours.Count; i++) | ||
692 | { | ||
693 | // Console.WriteLine("sending neighbours data"); | ||
694 | AgentCircuitData agent = remoteClient.RequestClientInfo(); | ||
695 | agent.BaseFolder = LLUUID.Zero; | ||
696 | agent.InventoryFolder = LLUUID.Zero; | ||
697 | agent.startpos = new LLVector3(128, 128, 70); | ||
698 | agent.child = true; | ||
699 | this.commsManager.InterRegion.InformRegionOfChildAgent(neighbours[i].RegionHandle, agent); | ||
700 | remoteClient.InformClientOfNeighbour(neighbours[i].RegionHandle, System.Net.IPAddress.Parse(neighbours[i].CommsIPListenAddr), (ushort)neighbours[i].CommsIPListenPort); | ||
701 | //this.capsHandlers[remoteClient.AgentId].CreateEstablishAgentComms("", System.Net.IPAddress.Parse(neighbours[i].CommsIPListenAddr) + ":" + neighbours[i].CommsIPListenPort); | ||
702 | } | ||
703 | } | ||
704 | } | ||
705 | |||
706 | /// <summary> | ||
707 | /// | ||
708 | /// </summary> | ||
709 | /// <param name="regionHandle"></param> | ||
710 | /// <returns></returns> | ||
711 | public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle) | ||
712 | { | ||
713 | return this.commsManager.GridServer.RequestNeighbourInfo(regionHandle); | ||
714 | } | ||
715 | |||
716 | /// <summary> | ||
717 | /// | ||
718 | /// </summary> | ||
719 | /// <param name="minX"></param> | ||
720 | /// <param name="minY"></param> | ||
721 | /// <param name="maxX"></param> | ||
722 | /// <param name="maxY"></param> | ||
723 | public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY) | ||
724 | { | ||
725 | List<MapBlockData> mapBlocks; | ||
726 | mapBlocks = this.commsManager.GridServer.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); | ||
727 | remoteClient.SendMapBlock(mapBlocks); | ||
728 | } | ||
729 | |||
730 | /// <summary> | ||
731 | /// | ||
732 | /// </summary> | ||
733 | /// <param name="remoteClient"></param> | ||
734 | /// <param name="RegionHandle"></param> | ||
735 | /// <param name="position"></param> | ||
736 | /// <param name="lookAt"></param> | ||
737 | /// <param name="flags"></param> | ||
738 | public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags) | ||
739 | { | ||
740 | if (regionHandle == this.m_regionHandle) | ||
741 | { | ||
742 | if (this.Avatars.ContainsKey(remoteClient.AgentId)) | ||
743 | { | ||
744 | remoteClient.SendTeleportLocationStart(); | ||
745 | remoteClient.SendLocalTeleport(position, lookAt, flags); | ||
746 | this.Avatars[remoteClient.AgentId].Teleport(position); | ||
747 | } | ||
748 | } | ||
749 | else | ||
750 | { | ||
751 | RegionInfo reg = this.RequestNeighbouringRegionInfo(regionHandle); | ||
752 | if (reg != null) | ||
753 | { | ||
754 | remoteClient.SendTeleportLocationStart(); | ||
755 | AgentCircuitData agent = remoteClient.RequestClientInfo(); | ||
756 | agent.BaseFolder = LLUUID.Zero; | ||
757 | agent.InventoryFolder = LLUUID.Zero; | ||
758 | agent.startpos = new LLVector3(128, 128, 70); | ||
759 | agent.child = true; | ||
760 | this.commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent); | ||
761 | this.commsManager.InterRegion.ExpectAvatarCrossing(regionHandle, remoteClient.AgentId, position); | ||
762 | remoteClient.SendRegionTeleport(regionHandle, 13, reg.CommsIPListenAddr, (ushort)reg.CommsIPListenPort, 4, (1 << 4)); | ||
763 | } | ||
764 | //remoteClient.SendTeleportCancel(); | ||
765 | } | ||
766 | } | ||
767 | |||
768 | /// <summary> | ||
769 | /// | ||
770 | /// </summary> | ||
771 | /// <param name="regionhandle"></param> | ||
772 | /// <param name="agentID"></param> | ||
773 | /// <param name="position"></param> | ||
774 | public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position) | ||
775 | { | ||
776 | return this.commsManager.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position); | ||
777 | } | ||
778 | |||
779 | #endregion | ||
780 | } | ||
781 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/SceneBase.cs b/OpenSim/OpenSim.Region/Scenes/SceneBase.cs deleted file mode 100644 index 5275fcf..0000000 --- a/OpenSim/OpenSim.Region/Scenes/SceneBase.cs +++ /dev/null | |||
@@ -1,200 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.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 libsecondlife; | ||
30 | using libsecondlife.Packets; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Text; | ||
33 | using System.Reflection; | ||
34 | using System.IO; | ||
35 | using System.Threading; | ||
36 | using OpenSim.Physics.Manager; | ||
37 | using OpenSim.Framework.Interfaces; | ||
38 | using OpenSim.Framework.Types; | ||
39 | using OpenSim.Framework.Inventory; | ||
40 | using OpenSim.Terrain; | ||
41 | using OpenSim.Caches; | ||
42 | |||
43 | namespace OpenSim.Region.Scenes | ||
44 | { | ||
45 | public abstract class SceneBase : IWorld | ||
46 | { | ||
47 | public Dictionary<libsecondlife.LLUUID, Entity> Entities; | ||
48 | protected Dictionary<uint, IClientAPI> m_clientThreads; | ||
49 | protected ulong m_regionHandle; | ||
50 | protected string m_regionName; | ||
51 | protected RegionInfo m_regInfo; | ||
52 | |||
53 | public TerrainEngine Terrain; | ||
54 | |||
55 | public string m_datastore; | ||
56 | public ILocalStorage localStorage; | ||
57 | |||
58 | protected object m_syncRoot = new object(); | ||
59 | private uint m_nextLocalId = 8880000; | ||
60 | protected AssetCache assetCache; | ||
61 | |||
62 | #region Update Methods | ||
63 | /// <summary> | ||
64 | /// Normally called once every frame/tick to let the world preform anything required (like running the physics simulation) | ||
65 | /// </summary> | ||
66 | public abstract void Update(); | ||
67 | |||
68 | #endregion | ||
69 | |||
70 | #region Terrain Methods | ||
71 | |||
72 | /// <summary> | ||
73 | /// Loads the World heightmap | ||
74 | /// </summary> | ||
75 | public abstract void LoadWorldMap(); | ||
76 | |||
77 | /// <summary> | ||
78 | /// Loads a new storage subsystem from a named library | ||
79 | /// </summary> | ||
80 | /// <param name="dllName">Storage Library</param> | ||
81 | /// <returns>Successful or not</returns> | ||
82 | public bool LoadStorageDLL(string dllName) | ||
83 | { | ||
84 | try | ||
85 | { | ||
86 | Assembly pluginAssembly = Assembly.LoadFrom(dllName); | ||
87 | ILocalStorage store = null; | ||
88 | |||
89 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
90 | { | ||
91 | if (pluginType.IsPublic) | ||
92 | { | ||
93 | if (!pluginType.IsAbstract) | ||
94 | { | ||
95 | Type typeInterface = pluginType.GetInterface("ILocalStorage", true); | ||
96 | |||
97 | if (typeInterface != null) | ||
98 | { | ||
99 | ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
100 | store = plug; | ||
101 | |||
102 | store.Initialise(this.m_datastore); | ||
103 | break; | ||
104 | } | ||
105 | |||
106 | typeInterface = null; | ||
107 | } | ||
108 | } | ||
109 | } | ||
110 | pluginAssembly = null; | ||
111 | this.localStorage = store; | ||
112 | return (store == null); | ||
113 | } | ||
114 | catch (Exception e) | ||
115 | { | ||
116 | OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: LoadStorageDLL() - Failed with exception " + e.ToString()); | ||
117 | return false; | ||
118 | } | ||
119 | } | ||
120 | |||
121 | |||
122 | /// <summary> | ||
123 | /// Send the region heightmap to the client | ||
124 | /// </summary> | ||
125 | /// <param name="RemoteClient">Client to send to</param> | ||
126 | public virtual void SendLayerData(IClientAPI RemoteClient) | ||
127 | { | ||
128 | RemoteClient.SendLayerData(Terrain.getHeights1D()); | ||
129 | } | ||
130 | |||
131 | /// <summary> | ||
132 | /// Sends a specified patch to a client | ||
133 | /// </summary> | ||
134 | /// <param name="px">Patch coordinate (x) 0..16</param> | ||
135 | /// <param name="py">Patch coordinate (y) 0..16</param> | ||
136 | /// <param name="RemoteClient">The client to send to</param> | ||
137 | public virtual void SendLayerData(int px, int py, IClientAPI RemoteClient) | ||
138 | { | ||
139 | RemoteClient.SendLayerData(px, py, Terrain.getHeights1D()); | ||
140 | } | ||
141 | |||
142 | #endregion | ||
143 | |||
144 | #region Add/Remove Agent/Avatar | ||
145 | /// <summary> | ||
146 | /// | ||
147 | /// </summary> | ||
148 | /// <param name="remoteClient"></param> | ||
149 | /// <param name="agentID"></param> | ||
150 | /// <param name="child"></param> | ||
151 | public abstract void AddNewClient(IClientAPI remoteClient, LLUUID agentID, bool child); | ||
152 | |||
153 | /// <summary> | ||
154 | /// | ||
155 | /// </summary> | ||
156 | /// <param name="agentID"></param> | ||
157 | public abstract void RemoveClient(LLUUID agentID); | ||
158 | |||
159 | #endregion | ||
160 | |||
161 | /// <summary> | ||
162 | /// | ||
163 | /// </summary> | ||
164 | /// <returns></returns> | ||
165 | public virtual RegionInfo RegionInfo | ||
166 | { | ||
167 | get { return this.m_regInfo; } | ||
168 | } | ||
169 | |||
170 | public object SyncRoot | ||
171 | { | ||
172 | get { return m_syncRoot; } | ||
173 | } | ||
174 | |||
175 | public uint NextLocalId | ||
176 | { | ||
177 | get { return m_nextLocalId++; } | ||
178 | } | ||
179 | |||
180 | #region Shutdown | ||
181 | /// <summary> | ||
182 | /// Tidy before shutdown | ||
183 | /// </summary> | ||
184 | public virtual void Close() | ||
185 | { | ||
186 | try | ||
187 | { | ||
188 | this.localStorage.ShutDown(); | ||
189 | } | ||
190 | catch (Exception e) | ||
191 | { | ||
192 | OpenSim.Framework.Console.MainLog.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "World.cs: Close() - Failed with exception " + e.ToString()); | ||
193 | } | ||
194 | } | ||
195 | |||
196 | #endregion | ||
197 | |||
198 | |||
199 | } | ||
200 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/SceneEvents.cs b/OpenSim/OpenSim.Region/Scenes/SceneEvents.cs deleted file mode 100644 index 4b39e51..0000000 --- a/OpenSim/OpenSim.Region/Scenes/SceneEvents.cs +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.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.Collections.Generic; | ||
30 | using System.Text; | ||
31 | |||
32 | namespace OpenSim.Region.Scenes | ||
33 | { | ||
34 | /// <summary> | ||
35 | /// A class for triggering remote scene events. | ||
36 | /// </summary> | ||
37 | public class EventManager | ||
38 | { | ||
39 | public delegate void OnFrameDelegate(); | ||
40 | public event OnFrameDelegate OnFrame; | ||
41 | |||
42 | public delegate void OnNewPresenceDelegate(ScenePresence presence); | ||
43 | public event OnNewPresenceDelegate OnNewPresence; | ||
44 | |||
45 | public delegate void OnNewPrimitiveDelegate(Primitive prim); | ||
46 | public event OnNewPrimitiveDelegate OnNewPrimitive; | ||
47 | |||
48 | public delegate void OnRemovePresenceDelegate(libsecondlife.LLUUID uuid); | ||
49 | public event OnRemovePresenceDelegate OnRemovePresence; | ||
50 | |||
51 | public void TriggerOnFrame() | ||
52 | { | ||
53 | if (OnFrame != null) | ||
54 | { | ||
55 | OnFrame(); | ||
56 | } | ||
57 | } | ||
58 | |||
59 | public void TriggerOnNewPrimitive(Primitive prim) | ||
60 | { | ||
61 | if (OnNewPrimitive != null) | ||
62 | OnNewPrimitive(prim); | ||
63 | } | ||
64 | |||
65 | public void TriggerOnNewPresence(ScenePresence presence) | ||
66 | { | ||
67 | if (OnNewPresence != null) | ||
68 | OnNewPresence(presence); | ||
69 | } | ||
70 | |||
71 | public void TriggerOnRemovePresence(libsecondlife.LLUUID uuid) | ||
72 | { | ||
73 | if (OnRemovePresence != null) | ||
74 | { | ||
75 | OnRemovePresence(uuid); | ||
76 | } | ||
77 | } | ||
78 | } | ||
79 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/SceneObject.cs b/OpenSim/OpenSim.Region/Scenes/SceneObject.cs deleted file mode 100644 index 5df87bf..0000000 --- a/OpenSim/OpenSim.Region/Scenes/SceneObject.cs +++ /dev/null | |||
@@ -1,128 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.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.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using libsecondlife; | ||
32 | using libsecondlife.Packets; | ||
33 | using OpenSim.Framework.Interfaces; | ||
34 | using OpenSim.Physics.Manager; | ||
35 | using OpenSim.Framework.Types; | ||
36 | using OpenSim.Framework.Inventory; | ||
37 | |||
38 | namespace OpenSim.Region.Scenes | ||
39 | { | ||
40 | public class SceneObject : Entity | ||
41 | { | ||
42 | private LLUUID rootUUID; | ||
43 | //private Dictionary<LLUUID, Primitive> ChildPrimitives = new Dictionary<LLUUID, Primitive>(); | ||
44 | protected Primitive rootPrimitive; | ||
45 | private Scene m_world; | ||
46 | protected ulong regionHandle; | ||
47 | |||
48 | /// <summary> | ||
49 | /// | ||
50 | /// </summary> | ||
51 | public SceneObject() | ||
52 | { | ||
53 | |||
54 | } | ||
55 | |||
56 | /// <summary> | ||
57 | /// | ||
58 | /// </summary> | ||
59 | /// <param name="addPacket"></param> | ||
60 | /// <param name="agentID"></param> | ||
61 | /// <param name="localID"></param> | ||
62 | public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID) | ||
63 | { | ||
64 | this.rootPrimitive = new Primitive( this.regionHandle, this.m_world, addPacket, agentID, localID); | ||
65 | } | ||
66 | |||
67 | /// <summary> | ||
68 | /// | ||
69 | /// </summary> | ||
70 | /// <param name="data"></param> | ||
71 | public void CreateFromBytes(byte[] data) | ||
72 | { | ||
73 | |||
74 | } | ||
75 | |||
76 | /// <summary> | ||
77 | /// | ||
78 | /// </summary> | ||
79 | public override void update() | ||
80 | { | ||
81 | |||
82 | } | ||
83 | |||
84 | /// <summary> | ||
85 | /// | ||
86 | /// </summary> | ||
87 | public override void BackUp() | ||
88 | { | ||
89 | |||
90 | } | ||
91 | |||
92 | /// <summary> | ||
93 | /// | ||
94 | /// </summary> | ||
95 | /// <param name="client"></param> | ||
96 | public void GetProperites(IClientAPI client) | ||
97 | { | ||
98 | //needs changing | ||
99 | ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); | ||
100 | proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; | ||
101 | proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); | ||
102 | proper.ObjectData[0].ItemID = LLUUID.Zero; | ||
103 | proper.ObjectData[0].CreationDate = (ulong)this.rootPrimitive.primData.CreationDate; | ||
104 | proper.ObjectData[0].CreatorID = this.rootPrimitive.primData.OwnerID; | ||
105 | proper.ObjectData[0].FolderID = LLUUID.Zero; | ||
106 | proper.ObjectData[0].FromTaskID = LLUUID.Zero; | ||
107 | proper.ObjectData[0].GroupID = LLUUID.Zero; | ||
108 | proper.ObjectData[0].InventorySerial = 0; | ||
109 | proper.ObjectData[0].LastOwnerID = LLUUID.Zero; | ||
110 | proper.ObjectData[0].ObjectID = this.uuid; | ||
111 | proper.ObjectData[0].OwnerID = this.rootPrimitive.primData.OwnerID; | ||
112 | proper.ObjectData[0].TouchName = new byte[0]; | ||
113 | proper.ObjectData[0].TextureID = new byte[0]; | ||
114 | proper.ObjectData[0].SitName = new byte[0]; | ||
115 | proper.ObjectData[0].Name = new byte[0]; | ||
116 | proper.ObjectData[0].Description = new byte[0]; | ||
117 | proper.ObjectData[0].OwnerMask = this.rootPrimitive.primData.OwnerMask; | ||
118 | proper.ObjectData[0].NextOwnerMask = this.rootPrimitive.primData.NextOwnerMask; | ||
119 | proper.ObjectData[0].GroupMask = this.rootPrimitive.primData.GroupMask; | ||
120 | proper.ObjectData[0].EveryoneMask = this.rootPrimitive.primData.EveryoneMask; | ||
121 | proper.ObjectData[0].BaseMask = this.rootPrimitive.primData.BaseMask; | ||
122 | |||
123 | client.OutPacket(proper); | ||
124 | |||
125 | } | ||
126 | |||
127 | } | ||
128 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/ScenePresence.Animations.cs b/OpenSim/OpenSim.Region/Scenes/ScenePresence.Animations.cs deleted file mode 100644 index f0a8721..0000000 --- a/OpenSim/OpenSim.Region/Scenes/ScenePresence.Animations.cs +++ /dev/null | |||
@@ -1,76 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.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.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using libsecondlife; | ||
32 | using System.Xml; | ||
33 | |||
34 | namespace OpenSim.Region.Scenes | ||
35 | { | ||
36 | partial class ScenePresence | ||
37 | { | ||
38 | public class AvatarAnimations | ||
39 | { | ||
40 | |||
41 | public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>(); | ||
42 | public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>(); | ||
43 | |||
44 | public AvatarAnimations() | ||
45 | { | ||
46 | } | ||
47 | |||
48 | public void LoadAnims() | ||
49 | { | ||
50 | //OpenSim.Framework.Console.MainLog.Instance.Verbose("Avatar.cs:LoadAnims() - Loading avatar animations"); | ||
51 | XmlTextReader reader = new XmlTextReader("data/avataranimations.xml"); | ||
52 | |||
53 | XmlDocument doc = new XmlDocument(); | ||
54 | doc.Load(reader); | ||
55 | foreach (XmlNode nod in doc.DocumentElement.ChildNodes) | ||
56 | { | ||
57 | |||
58 | if (nod.Attributes["name"] != null) | ||
59 | { | ||
60 | AnimsLLUUID.Add(nod.Attributes["name"].Value, nod.InnerText); | ||
61 | } | ||
62 | |||
63 | } | ||
64 | |||
65 | reader.Close(); | ||
66 | |||
67 | // OpenSim.Framework.Console.MainLog.Instance.Verbose("Loaded " + AnimsLLUUID.Count.ToString() + " animation(s)"); | ||
68 | |||
69 | foreach (KeyValuePair<string, LLUUID> kp in OpenSim.Region.Scenes.ScenePresence.Animations.AnimsLLUUID) | ||
70 | { | ||
71 | AnimsNames.Add(kp.Value, kp.Key); | ||
72 | } | ||
73 | } | ||
74 | } | ||
75 | } | ||
76 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/ScenePresence.Body.cs b/OpenSim/OpenSim.Region/Scenes/ScenePresence.Body.cs deleted file mode 100644 index d21b11f..0000000 --- a/OpenSim/OpenSim.Region/Scenes/ScenePresence.Body.cs +++ /dev/null | |||
@@ -1,90 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.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.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using libsecondlife; | ||
32 | using libsecondlife.Packets; | ||
33 | using OpenSim.Physics.Manager; | ||
34 | using OpenSim.Framework.Interfaces; | ||
35 | using OpenSim.Framework.Types; | ||
36 | |||
37 | namespace OpenSim.Region.Scenes | ||
38 | { | ||
39 | partial class ScenePresence | ||
40 | { | ||
41 | public class Avatar : IScenePresenceBody | ||
42 | { | ||
43 | public Avatar() | ||
44 | { | ||
45 | |||
46 | } | ||
47 | |||
48 | public void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) | ||
49 | { | ||
50 | } | ||
51 | |||
52 | public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) | ||
53 | { | ||
54 | } | ||
55 | |||
56 | public void SendOurAppearance(IClientAPI OurClient) | ||
57 | { | ||
58 | } | ||
59 | |||
60 | public void SendAppearanceToOtherAgent(ScenePresence avatarInfo) | ||
61 | { | ||
62 | } | ||
63 | } | ||
64 | |||
65 | public class ChildAgent : IScenePresenceBody //is a ghost | ||
66 | { | ||
67 | public ChildAgent() | ||
68 | { | ||
69 | |||
70 | } | ||
71 | |||
72 | public void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) | ||
73 | { | ||
74 | } | ||
75 | |||
76 | public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) | ||
77 | { | ||
78 | } | ||
79 | |||
80 | public void SendOurAppearance(IClientAPI OurClient) | ||
81 | { | ||
82 | } | ||
83 | |||
84 | public void SendAppearanceToOtherAgent(ScenePresence avatarInfo) | ||
85 | { | ||
86 | } | ||
87 | } | ||
88 | } | ||
89 | |||
90 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/ScenePresence.cs b/OpenSim/OpenSim.Region/Scenes/ScenePresence.cs deleted file mode 100644 index 45d3fed..0000000 --- a/OpenSim/OpenSim.Region/Scenes/ScenePresence.cs +++ /dev/null | |||
@@ -1,525 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.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.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Text; | ||
32 | using libsecondlife; | ||
33 | using libsecondlife.Packets; | ||
34 | using OpenSim.Physics.Manager; | ||
35 | using OpenSim.Framework.Inventory; | ||
36 | using OpenSim.Framework.Interfaces; | ||
37 | using OpenSim.Framework.Types; | ||
38 | using Axiom.MathLib; | ||
39 | |||
40 | namespace OpenSim.Region.Scenes | ||
41 | { | ||
42 | public partial class ScenePresence : Entity | ||
43 | { | ||
44 | public static bool PhysicsEngineFlying = false; | ||
45 | public static AvatarAnimations Animations; | ||
46 | public static byte[] DefaultTexture; | ||
47 | public string firstname; | ||
48 | public string lastname; | ||
49 | public IClientAPI ControllingClient; | ||
50 | public LLUUID current_anim; | ||
51 | public int anim_seq; | ||
52 | private bool updateflag = false; | ||
53 | private byte movementflag = 0; | ||
54 | private List<NewForce> forcesList = new List<NewForce>(); | ||
55 | private short _updateCount = 0; | ||
56 | private Axiom.MathLib.Quaternion bodyRot; | ||
57 | private LLObject.TextureEntry avatarAppearanceTexture = null; | ||
58 | private byte[] visualParams; | ||
59 | private AvatarWearable[] Wearables; | ||
60 | private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); | ||
61 | private ulong m_regionHandle; | ||
62 | private bool childAgent = false; | ||
63 | private bool newForce = false; | ||
64 | private bool newAvatar = false; | ||
65 | private IScenePresenceBody m_body; | ||
66 | |||
67 | protected RegionInfo m_regionInfo; | ||
68 | |||
69 | #region Properties | ||
70 | /// <summary> | ||
71 | /// | ||
72 | /// </summary> | ||
73 | public PhysicsActor PhysActor | ||
74 | { | ||
75 | set | ||
76 | { | ||
77 | this._physActor = value; | ||
78 | } | ||
79 | get | ||
80 | { | ||
81 | return _physActor; | ||
82 | } | ||
83 | } | ||
84 | #endregion | ||
85 | |||
86 | #region Constructor(s) | ||
87 | /// <summary> | ||
88 | /// | ||
89 | /// </summary> | ||
90 | /// <param name="theClient"></param> | ||
91 | /// <param name="world"></param> | ||
92 | /// <param name="clientThreads"></param> | ||
93 | /// <param name="regionDat"></param> | ||
94 | public ScenePresence(IClientAPI theClient, Scene world, RegionInfo reginfo) | ||
95 | { | ||
96 | |||
97 | m_world = world; | ||
98 | this.uuid = theClient.AgentId; | ||
99 | |||
100 | m_regionInfo = reginfo; | ||
101 | m_regionHandle = reginfo.RegionHandle; | ||
102 | OpenSim.Framework.Console.MainLog.Instance.Verbose("Avatar.cs "); | ||
103 | ControllingClient = theClient; | ||
104 | this.firstname = ControllingClient.FirstName; | ||
105 | this.lastname = ControllingClient.LastName; | ||
106 | m_localId = m_world.NextLocalId; | ||
107 | Pos = ControllingClient.StartPos; | ||
108 | visualParams = new byte[218]; | ||
109 | for (int i = 0; i < 218; i++) | ||
110 | { | ||
111 | visualParams[i] = 100; | ||
112 | } | ||
113 | |||
114 | Wearables = AvatarWearable.DefaultWearables; | ||
115 | |||
116 | this.avatarAppearanceTexture = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); | ||
117 | |||
118 | //register for events | ||
119 | ControllingClient.OnRequestWearables += this.SendOurAppearance; | ||
120 | //ControllingClient.OnSetAppearance += new SetAppearance(this.SetAppearance); | ||
121 | ControllingClient.OnCompleteMovementToRegion += this.CompleteMovement; | ||
122 | ControllingClient.OnCompleteMovementToRegion += this.SendInitialData; | ||
123 | ControllingClient.OnAgentUpdate += this.HandleAgentUpdate; | ||
124 | // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); | ||
125 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); | ||
126 | //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); | ||
127 | |||
128 | } | ||
129 | #endregion | ||
130 | |||
131 | #region Status Methods | ||
132 | /// <summary> | ||
133 | /// Not Used, most likely can be deleted | ||
134 | /// </summary> | ||
135 | /// <param name="status"></param> | ||
136 | public void ChildStatusChange(bool status) | ||
137 | { | ||
138 | this.childAgent = status; | ||
139 | |||
140 | if (this.childAgent == true) | ||
141 | { | ||
142 | this.Velocity = new LLVector3(0, 0, 0); | ||
143 | this.Pos = new LLVector3(128, 128, 70); | ||
144 | |||
145 | } | ||
146 | } | ||
147 | |||
148 | /// <summary> | ||
149 | /// | ||
150 | /// </summary> | ||
151 | /// <param name="pos"></param> | ||
152 | public void MakeAvatar(LLVector3 pos) | ||
153 | { | ||
154 | //this.childAvatar = false; | ||
155 | this.Pos = pos; | ||
156 | this.newAvatar = true; | ||
157 | this.childAgent = false; | ||
158 | } | ||
159 | |||
160 | protected void MakeChildAgent() | ||
161 | { | ||
162 | this.Velocity = new LLVector3(0, 0, 0); | ||
163 | this.Pos = new LLVector3(128, 128, 70); | ||
164 | this.childAgent = true; | ||
165 | } | ||
166 | |||
167 | /// <summary> | ||
168 | /// | ||
169 | /// </summary> | ||
170 | /// <param name="pos"></param> | ||
171 | public void Teleport(LLVector3 pos) | ||
172 | { | ||
173 | this.Pos = pos; | ||
174 | this.SendTerseUpdateToALLClients(); | ||
175 | } | ||
176 | |||
177 | /// <summary> | ||
178 | /// | ||
179 | /// </summary> | ||
180 | public void StopMovement() | ||
181 | { | ||
182 | |||
183 | } | ||
184 | #endregion | ||
185 | |||
186 | #region Event Handlers | ||
187 | /// <summary> | ||
188 | /// | ||
189 | /// </summary> | ||
190 | /// <param name="texture"></param> | ||
191 | /// <param name="visualParam"></param> | ||
192 | public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) | ||
193 | { | ||
194 | |||
195 | } | ||
196 | |||
197 | /// <summary> | ||
198 | /// Complete Avatar's movement into the region | ||
199 | /// </summary> | ||
200 | public void CompleteMovement() | ||
201 | { | ||
202 | LLVector3 look = this.Velocity; | ||
203 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) | ||
204 | { | ||
205 | look = new LLVector3(0.99f, 0.042f, 0); | ||
206 | } | ||
207 | this.ControllingClient.MoveAgentIntoRegion(m_regionInfo, Pos, look); | ||
208 | if (this.childAgent) | ||
209 | { | ||
210 | this.childAgent = false; | ||
211 | } | ||
212 | } | ||
213 | |||
214 | /// <summary> | ||
215 | /// | ||
216 | /// </summary> | ||
217 | /// <param name="pack"></param> | ||
218 | public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) | ||
219 | { | ||
220 | if ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS) != 0) | ||
221 | { | ||
222 | Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z); | ||
223 | if (((movementflag & 1) == 0) || (q != this.bodyRot)) | ||
224 | { | ||
225 | Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0); | ||
226 | this.AddNewMovement(v3, q); | ||
227 | movementflag = 1; | ||
228 | this.bodyRot = q; | ||
229 | } | ||
230 | } | ||
231 | else if ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_AT_NEG) != 0) | ||
232 | { | ||
233 | Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z); | ||
234 | if (((movementflag & 2) == 0) || (q != this.bodyRot)) | ||
235 | { | ||
236 | Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(-1, 0, 0); | ||
237 | this.AddNewMovement(v3, q); | ||
238 | movementflag = 2; | ||
239 | this.bodyRot = q; | ||
240 | } | ||
241 | } | ||
242 | else | ||
243 | { | ||
244 | if ((movementflag) != 0) | ||
245 | { | ||
246 | NewForce newVelocity = new NewForce(); | ||
247 | newVelocity.X = 0; | ||
248 | newVelocity.Y = 0; | ||
249 | newVelocity.Z = 0; | ||
250 | this.forcesList.Add(newVelocity); | ||
251 | movementflag = 0; | ||
252 | } | ||
253 | } | ||
254 | |||
255 | } | ||
256 | |||
257 | protected void AddNewMovement(Axiom.MathLib.Vector3 vec, Axiom.MathLib.Quaternion rotation) | ||
258 | { | ||
259 | NewForce newVelocity = new NewForce(); | ||
260 | Axiom.MathLib.Vector3 direc = rotation * vec; | ||
261 | direc.Normalize(); | ||
262 | |||
263 | direc = direc * ((0.03f) * 128f); | ||
264 | if (this._physActor.Flying) | ||
265 | direc *= 4; | ||
266 | |||
267 | newVelocity.X = direc.x; | ||
268 | newVelocity.Y = direc.y; | ||
269 | newVelocity.Z = direc.z; | ||
270 | this.forcesList.Add(newVelocity); | ||
271 | } | ||
272 | |||
273 | #endregion | ||
274 | |||
275 | #region Overridden Methods | ||
276 | /// <summary> | ||
277 | /// | ||
278 | /// </summary> | ||
279 | public override void LandRenegerated() | ||
280 | { | ||
281 | |||
282 | } | ||
283 | |||
284 | /// <summary> | ||
285 | /// | ||
286 | /// </summary> | ||
287 | public override void update() | ||
288 | { | ||
289 | if (this.childAgent == false) | ||
290 | { | ||
291 | if (this.newForce) | ||
292 | { | ||
293 | this.SendTerseUpdateToALLClients(); | ||
294 | _updateCount = 0; | ||
295 | } | ||
296 | else if (movementflag != 0) | ||
297 | { | ||
298 | _updateCount++; | ||
299 | if (_updateCount > 3) | ||
300 | { | ||
301 | this.SendTerseUpdateToALLClients(); | ||
302 | _updateCount = 0; | ||
303 | } | ||
304 | } | ||
305 | |||
306 | this.CheckForBorderCrossing(); | ||
307 | } | ||
308 | } | ||
309 | #endregion | ||
310 | |||
311 | #region Update Client(s) | ||
312 | /// <summary> | ||
313 | /// | ||
314 | /// </summary> | ||
315 | /// <param name="RemoteClient"></param> | ||
316 | public void SendTerseUpdateToClient(IClientAPI RemoteClient) | ||
317 | { | ||
318 | LLVector3 pos = this.Pos; | ||
319 | LLVector3 vel = this.Velocity; | ||
320 | RemoteClient.SendAvatarTerseUpdate(this.m_regionHandle, 64096, this.LocalId, new LLVector3(pos.X, pos.Y, pos.Z), new LLVector3(vel.X, vel.Y, vel.Z)); | ||
321 | } | ||
322 | |||
323 | /// <summary> | ||
324 | /// | ||
325 | /// </summary> | ||
326 | public void SendTerseUpdateToALLClients() | ||
327 | { | ||
328 | List<ScenePresence> avatars = this.m_world.RequestAvatarList(); | ||
329 | for (int i = 0; i < avatars.Count; i++) | ||
330 | { | ||
331 | this.SendTerseUpdateToClient(avatars[i].ControllingClient); | ||
332 | } | ||
333 | } | ||
334 | |||
335 | /// <summary> | ||
336 | /// | ||
337 | /// </summary> | ||
338 | /// <param name="remoteAvatar"></param> | ||
339 | public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) | ||
340 | { | ||
341 | remoteAvatar.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos, DefaultTexture); | ||
342 | } | ||
343 | |||
344 | /// <summary> | ||
345 | /// | ||
346 | /// </summary> | ||
347 | public void SendInitialData() | ||
348 | { | ||
349 | this.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos, DefaultTexture); | ||
350 | if (this.newAvatar) | ||
351 | { | ||
352 | this.m_world.InformClientOfNeighbours(this.ControllingClient); | ||
353 | this.newAvatar = false; | ||
354 | } | ||
355 | } | ||
356 | |||
357 | /// <summary> | ||
358 | /// | ||
359 | /// </summary> | ||
360 | /// <param name="OurClient"></param> | ||
361 | public void SendOurAppearance(IClientAPI OurClient) | ||
362 | { | ||
363 | this.ControllingClient.SendWearables(this.Wearables); | ||
364 | } | ||
365 | |||
366 | /// <summary> | ||
367 | /// | ||
368 | /// </summary> | ||
369 | /// <param name="avatarInfo"></param> | ||
370 | public void SendAppearanceToOtherAgent(ScenePresence avatarInfo) | ||
371 | { | ||
372 | |||
373 | } | ||
374 | |||
375 | /// <summary> | ||
376 | /// | ||
377 | /// </summary> | ||
378 | /// <param name="animID"></param> | ||
379 | /// <param name="seq"></param> | ||
380 | public void SendAnimPack(LLUUID animID, int seq) | ||
381 | { | ||
382 | |||
383 | |||
384 | } | ||
385 | |||
386 | /// <summary> | ||
387 | /// | ||
388 | /// </summary> | ||
389 | public void SendAnimPack() | ||
390 | { | ||
391 | |||
392 | } | ||
393 | #endregion | ||
394 | |||
395 | #region Border Crossing Methods | ||
396 | /// <summary> | ||
397 | /// | ||
398 | /// </summary> | ||
399 | protected void CheckForBorderCrossing() | ||
400 | { | ||
401 | LLVector3 pos2 = this.Pos; | ||
402 | LLVector3 vel = this.Velocity; | ||
403 | |||
404 | float timeStep = 0.2f; | ||
405 | pos2.X = pos2.X + (vel.X * timeStep); | ||
406 | pos2.Y = pos2.Y + (vel.Y * timeStep); | ||
407 | pos2.Z = pos2.Z + (vel.Z * timeStep); | ||
408 | |||
409 | if ((pos2.X < 0) || (pos2.X > 256)) | ||
410 | { | ||
411 | this.CrossToNewRegion(); | ||
412 | } | ||
413 | |||
414 | if ((pos2.Y < 0) || (pos2.Y > 256)) | ||
415 | { | ||
416 | this.CrossToNewRegion(); | ||
417 | } | ||
418 | } | ||
419 | |||
420 | /// <summary> | ||
421 | /// | ||
422 | /// </summary> | ||
423 | protected void CrossToNewRegion() | ||
424 | { | ||
425 | LLVector3 pos = this.Pos; | ||
426 | LLVector3 newpos = new LLVector3(pos.X, pos.Y, pos.Z); | ||
427 | uint neighbourx = this.m_regionInfo.RegionLocX; | ||
428 | uint neighboury = this.m_regionInfo.RegionLocY; | ||
429 | |||
430 | if (pos.X < 2) | ||
431 | { | ||
432 | neighbourx -= 1; | ||
433 | newpos.X = 254; | ||
434 | } | ||
435 | if (pos.X > 253) | ||
436 | { | ||
437 | neighbourx += 1; | ||
438 | newpos.X = 1; | ||
439 | } | ||
440 | if (pos.Y < 2) | ||
441 | { | ||
442 | neighboury -= 1; | ||
443 | newpos.Y = 254; | ||
444 | } | ||
445 | if (pos.Y > 253) | ||
446 | { | ||
447 | neighboury += 1; | ||
448 | newpos.Y = 1; | ||
449 | } | ||
450 | |||
451 | LLVector3 vel = this.velocity; | ||
452 | ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * 256), (uint)(neighboury * 256)); | ||
453 | RegionInfo neighbourRegion = this.m_world.RequestNeighbouringRegionInfo(neighbourHandle); | ||
454 | if (neighbourRegion != null) | ||
455 | { | ||
456 | bool res = this.m_world.InformNeighbourOfCrossing(neighbourHandle, this.ControllingClient.AgentId, newpos); | ||
457 | if (res) | ||
458 | { | ||
459 | this.MakeChildAgent(); | ||
460 | this.ControllingClient.CrossRegion(neighbourHandle, newpos, vel, System.Net.IPAddress.Parse(neighbourRegion.CommsIPListenAddr), (ushort)neighbourRegion.CommsIPListenPort); | ||
461 | } | ||
462 | } | ||
463 | } | ||
464 | #endregion | ||
465 | |||
466 | /// <summary> | ||
467 | /// | ||
468 | /// </summary> | ||
469 | public static void LoadAnims() | ||
470 | { | ||
471 | |||
472 | } | ||
473 | |||
474 | /// <summary> | ||
475 | /// | ||
476 | /// </summary> | ||
477 | public override void updateMovement() | ||
478 | { | ||
479 | newForce = false; | ||
480 | lock (this.forcesList) | ||
481 | { | ||
482 | if (this.forcesList.Count > 0) | ||
483 | { | ||
484 | for (int i = 0; i < this.forcesList.Count; i++) | ||
485 | { | ||
486 | NewForce force = this.forcesList[i]; | ||
487 | |||
488 | this.updateflag = true; | ||
489 | this.Velocity = new LLVector3(force.X, force.Y, force.Z); | ||
490 | this.newForce = true; | ||
491 | } | ||
492 | for (int i = 0; i < this.forcesList.Count; i++) | ||
493 | { | ||
494 | this.forcesList.RemoveAt(0); | ||
495 | } | ||
496 | } | ||
497 | } | ||
498 | } | ||
499 | |||
500 | public static void LoadTextureFile(string name) | ||
501 | { | ||
502 | FileInfo fInfo = new FileInfo(name); | ||
503 | long numBytes = fInfo.Length; | ||
504 | FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); | ||
505 | BinaryReader br = new BinaryReader(fStream); | ||
506 | byte[] data1 = br.ReadBytes((int)numBytes); | ||
507 | br.Close(); | ||
508 | fStream.Close(); | ||
509 | DefaultTexture = data1; | ||
510 | } | ||
511 | |||
512 | public class NewForce | ||
513 | { | ||
514 | public float X; | ||
515 | public float Y; | ||
516 | public float Z; | ||
517 | |||
518 | public NewForce() | ||
519 | { | ||
520 | |||
521 | } | ||
522 | } | ||
523 | } | ||
524 | |||
525 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/Engines/CSharpScriptEngine.cs b/OpenSim/OpenSim.Region/Scenes/scripting/Engines/CSharpScriptEngine.cs deleted file mode 100644 index 870303f..0000000 --- a/OpenSim/OpenSim.Region/Scenes/scripting/Engines/CSharpScriptEngine.cs +++ /dev/null | |||
@@ -1,104 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.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.Collections.Generic; | ||
30 | using System.Text; | ||
31 | |||
32 | // Compilation stuff | ||
33 | using System.CodeDom; | ||
34 | using System.CodeDom.Compiler; | ||
35 | using Microsoft.CSharp; | ||
36 | |||
37 | namespace OpenSim.Scripting | ||
38 | { | ||
39 | public class CSharpScriptEngine : IScriptCompiler | ||
40 | { | ||
41 | public string FileExt() | ||
42 | { | ||
43 | return ".cs"; | ||
44 | } | ||
45 | |||
46 | private Dictionary<string,IScript> LoadDotNetScript(ICodeCompiler compiler, string filename) | ||
47 | { | ||
48 | CompilerParameters compilerParams = new CompilerParameters(); | ||
49 | CompilerResults compilerResults; | ||
50 | compilerParams.GenerateExecutable = false; | ||
51 | compilerParams.GenerateInMemory = true; | ||
52 | compilerParams.IncludeDebugInformation = false; | ||
53 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll"); | ||
54 | compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll"); | ||
55 | compilerParams.ReferencedAssemblies.Add("libsecondlife.dll"); | ||
56 | compilerParams.ReferencedAssemblies.Add("System.dll"); | ||
57 | |||
58 | compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename); | ||
59 | |||
60 | if (compilerResults.Errors.Count > 0) | ||
61 | { | ||
62 | OpenSim.Framework.Console.MainLog.Instance.Error("Compile errors"); | ||
63 | foreach (CompilerError error in compilerResults.Errors) | ||
64 | { | ||
65 | OpenSim.Framework.Console.MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString()); | ||
66 | } | ||
67 | } | ||
68 | else | ||
69 | { | ||
70 | Dictionary<string,IScript> scripts = new Dictionary<string,IScript>(); | ||
71 | |||
72 | foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes()) | ||
73 | { | ||
74 | Type testInterface = pluginType.GetInterface("IScript", true); | ||
75 | |||
76 | if (testInterface != null) | ||
77 | { | ||
78 | IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); | ||
79 | |||
80 | string scriptName = "C#/" + script.getName(); | ||
81 | Console.WriteLine("Script: " + scriptName + " loaded."); | ||
82 | |||
83 | if (!scripts.ContainsKey(scriptName)) | ||
84 | { | ||
85 | scripts.Add(scriptName, script); | ||
86 | } | ||
87 | else | ||
88 | { | ||
89 | scripts[scriptName] = script; | ||
90 | } | ||
91 | } | ||
92 | } | ||
93 | return scripts; | ||
94 | } | ||
95 | return null; | ||
96 | } | ||
97 | |||
98 | public Dictionary<string,IScript> compile(string filename) | ||
99 | { | ||
100 | CSharpCodeProvider csharpProvider = new CSharpCodeProvider(); | ||
101 | return LoadDotNetScript(csharpProvider.CreateCompiler(), filename); | ||
102 | } | ||
103 | } | ||
104 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/Engines/JScriptEngine.cs b/OpenSim/OpenSim.Region/Scenes/scripting/Engines/JScriptEngine.cs deleted file mode 100644 index ffae1d7..0000000 --- a/OpenSim/OpenSim.Region/Scenes/scripting/Engines/JScriptEngine.cs +++ /dev/null | |||
@@ -1,104 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.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.Collections.Generic; | ||
30 | using System.Text; | ||
31 | |||
32 | // Compilation stuff | ||
33 | using System.CodeDom; | ||
34 | using System.CodeDom.Compiler; | ||
35 | using Microsoft.JScript; | ||
36 | |||
37 | namespace OpenSim.Scripting | ||
38 | { | ||
39 | public class JScriptEngine : IScriptCompiler | ||
40 | { | ||
41 | public string FileExt() | ||
42 | { | ||
43 | return ".js"; | ||
44 | } | ||
45 | |||
46 | private Dictionary<string, IScript> LoadDotNetScript(ICodeCompiler compiler, string filename) | ||
47 | { | ||
48 | CompilerParameters compilerParams = new CompilerParameters(); | ||
49 | CompilerResults compilerResults; | ||
50 | compilerParams.GenerateExecutable = false; | ||
51 | compilerParams.GenerateInMemory = true; | ||
52 | compilerParams.IncludeDebugInformation = false; | ||
53 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll"); | ||
54 | compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll"); | ||
55 | compilerParams.ReferencedAssemblies.Add("libsecondlife.dll"); | ||
56 | compilerParams.ReferencedAssemblies.Add("System.dll"); | ||
57 | |||
58 | compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename); | ||
59 | |||
60 | if (compilerResults.Errors.Count > 0) | ||
61 | { | ||
62 | OpenSim.Framework.Console.MainLog.Instance.Error("Compile errors"); | ||
63 | foreach (CompilerError error in compilerResults.Errors) | ||
64 | { | ||
65 | OpenSim.Framework.Console.MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString()); | ||
66 | } | ||
67 | } | ||
68 | else | ||
69 | { | ||
70 | Dictionary<string, IScript> scripts = new Dictionary<string, IScript>(); | ||
71 | |||
72 | foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes()) | ||
73 | { | ||
74 | Type testInterface = pluginType.GetInterface("IScript", true); | ||
75 | |||
76 | if (testInterface != null) | ||
77 | { | ||
78 | IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); | ||
79 | |||
80 | string scriptName = "JS.NET/" + script.getName(); | ||
81 | Console.WriteLine("Script: " + scriptName + " loaded."); | ||
82 | |||
83 | if (!scripts.ContainsKey(scriptName)) | ||
84 | { | ||
85 | scripts.Add(scriptName, script); | ||
86 | } | ||
87 | else | ||
88 | { | ||
89 | scripts[scriptName] = script; | ||
90 | } | ||
91 | } | ||
92 | } | ||
93 | return scripts; | ||
94 | } | ||
95 | return null; | ||
96 | } | ||
97 | |||
98 | public Dictionary<string, IScript> compile(string filename) | ||
99 | { | ||
100 | JScriptCodeProvider jscriptProvider = new JScriptCodeProvider(); | ||
101 | return LoadDotNetScript(jscriptProvider.CreateCompiler(), filename); | ||
102 | } | ||
103 | } | ||
104 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/Engines/JSharpScriptEngine.cs b/OpenSim/OpenSim.Region/Scenes/scripting/Engines/JSharpScriptEngine.cs deleted file mode 100644 index b33b55d..0000000 --- a/OpenSim/OpenSim.Region/Scenes/scripting/Engines/JSharpScriptEngine.cs +++ /dev/null | |||
@@ -1,104 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.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.Collections.Generic; | ||
30 | using System.Text; | ||
31 | |||
32 | // Compilation stuff | ||
33 | using System.CodeDom; | ||
34 | using System.CodeDom.Compiler; | ||
35 | using Microsoft.VJSharp; | ||
36 | |||
37 | namespace OpenSim.Scripting | ||
38 | { | ||
39 | public class JSharpScriptEngine : IScriptCompiler | ||
40 | { | ||
41 | public string FileExt() | ||
42 | { | ||
43 | return ".jsl"; | ||
44 | } | ||
45 | |||
46 | private Dictionary<string, IScript> LoadDotNetScript(ICodeCompiler compiler, string filename) | ||
47 | { | ||
48 | CompilerParameters compilerParams = new CompilerParameters(); | ||
49 | CompilerResults compilerResults; | ||
50 | compilerParams.GenerateExecutable = false; | ||
51 | compilerParams.GenerateInMemory = true; | ||
52 | compilerParams.IncludeDebugInformation = false; | ||
53 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll"); | ||
54 | compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll"); | ||
55 | compilerParams.ReferencedAssemblies.Add("libsecondlife.dll"); | ||
56 | compilerParams.ReferencedAssemblies.Add("System.dll"); | ||
57 | |||
58 | compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename); | ||
59 | |||
60 | if (compilerResults.Errors.Count > 0) | ||
61 | { | ||
62 | OpenSim.Framework.Console.MainLog.Instance.Error("Compile errors"); | ||
63 | foreach (CompilerError error in compilerResults.Errors) | ||
64 | { | ||
65 | OpenSim.Framework.Console.MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString()); | ||
66 | } | ||
67 | } | ||
68 | else | ||
69 | { | ||
70 | Dictionary<string, IScript> scripts = new Dictionary<string, IScript>(); | ||
71 | |||
72 | foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes()) | ||
73 | { | ||
74 | Type testInterface = pluginType.GetInterface("IScript", true); | ||
75 | |||
76 | if (testInterface != null) | ||
77 | { | ||
78 | IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); | ||
79 | |||
80 | string scriptName = "J#/" + script.getName(); | ||
81 | Console.WriteLine("Script: " + scriptName + " loaded."); | ||
82 | |||
83 | if (!scripts.ContainsKey(scriptName)) | ||
84 | { | ||
85 | scripts.Add(scriptName, script); | ||
86 | } | ||
87 | else | ||
88 | { | ||
89 | scripts[scriptName] = script; | ||
90 | } | ||
91 | } | ||
92 | } | ||
93 | return scripts; | ||
94 | } | ||
95 | return null; | ||
96 | } | ||
97 | |||
98 | public Dictionary<string, IScript> compile(string filename) | ||
99 | { | ||
100 | VJSharpCodeProvider jsharpProvider = new VJSharpCodeProvider(); | ||
101 | return LoadDotNetScript(jsharpProvider.CreateCompiler(), filename); | ||
102 | } | ||
103 | } | ||
104 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/Script.cs b/OpenSim/OpenSim.Region/Scenes/scripting/Script.cs deleted file mode 100644 index 56bd1db..0000000 --- a/OpenSim/OpenSim.Region/Scenes/scripting/Script.cs +++ /dev/null | |||
@@ -1,71 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.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.Collections.Generic; | ||
30 | using System.Text; | ||
31 | |||
32 | using OpenSim.Framework.Console; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Region; | ||
35 | using OpenSim.Region.Scenes; | ||
36 | |||
37 | namespace OpenSim.Scripting | ||
38 | { | ||
39 | public interface IScript | ||
40 | { | ||
41 | void Initialise(ScriptInfo scriptInfo); | ||
42 | string getName(); | ||
43 | } | ||
44 | |||
45 | public class TestScript : IScript | ||
46 | { | ||
47 | ScriptInfo script; | ||
48 | |||
49 | public string getName() | ||
50 | { | ||
51 | return "TestScript 0.1"; | ||
52 | } | ||
53 | |||
54 | public void Initialise(ScriptInfo scriptInfo) | ||
55 | { | ||
56 | script = scriptInfo; | ||
57 | script.events.OnFrame += new OpenSim.Region.Scenes.EventManager.OnFrameDelegate(events_OnFrame); | ||
58 | script.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence); | ||
59 | } | ||
60 | |||
61 | void events_OnNewPresence(ScenePresence presence) | ||
62 | { | ||
63 | script.logger.Verbose("Hello " + presence.firstname.ToString() + "!"); | ||
64 | } | ||
65 | |||
66 | void events_OnFrame() | ||
67 | { | ||
68 | //script.logger.Verbose("Hello World!"); | ||
69 | } | ||
70 | } | ||
71 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/ScriptInfo.cs b/OpenSim/OpenSim.Region/Scenes/scripting/ScriptInfo.cs deleted file mode 100644 index cf627dd..0000000 --- a/OpenSim/OpenSim.Region/Scenes/scripting/ScriptInfo.cs +++ /dev/null | |||
@@ -1,58 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.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.Collections.Generic; | ||
30 | using System.Text; | ||
31 | |||
32 | using OpenSim.Region.Scenes; | ||
33 | using OpenSim.Framework.Console; | ||
34 | |||
35 | namespace OpenSim.Scripting | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// Class which provides access to the world | ||
39 | /// </summary> | ||
40 | public class ScriptInfo | ||
41 | { | ||
42 | // Reference to world.eventsManager provided for convenience | ||
43 | public EventManager events; | ||
44 | |||
45 | // The main world | ||
46 | public Scene world; | ||
47 | |||
48 | // The console | ||
49 | public LogBase logger; | ||
50 | |||
51 | public ScriptInfo(Scene scene) | ||
52 | { | ||
53 | world = scene; | ||
54 | events = world.eventManager; | ||
55 | logger = OpenSim.Framework.Console.MainLog.Instance; | ||
56 | } | ||
57 | } | ||
58 | } | ||
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/ScriptManager.cs b/OpenSim/OpenSim.Region/Scenes/scripting/ScriptManager.cs deleted file mode 100644 index abffffa..0000000 --- a/OpenSim/OpenSim.Region/Scenes/scripting/ScriptManager.cs +++ /dev/null | |||
@@ -1,99 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.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.Collections.Generic; | ||
30 | using System.Text; | ||
31 | |||
32 | namespace OpenSim.Scripting | ||
33 | { | ||
34 | public class ScriptManager | ||
35 | { | ||
36 | List<IScript> scripts = new List<IScript>(); | ||
37 | OpenSim.Region.Scenes.Scene scene; | ||
38 | Dictionary<string, IScriptCompiler> compilers = new Dictionary<string, IScriptCompiler>(); | ||
39 | |||
40 | private void LoadFromCompiler(Dictionary<string, IScript> compiledscripts) | ||
41 | { | ||
42 | foreach (KeyValuePair<string, IScript> script in compiledscripts) | ||
43 | { | ||
44 | ScriptInfo scriptInfo = new ScriptInfo(scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. | ||
45 | OpenSim.Framework.Console.MainLog.Instance.Verbose("Loading " + script.Key); | ||
46 | script.Value.Initialise(scriptInfo); | ||
47 | scripts.Add(script.Value); | ||
48 | } | ||
49 | OpenSim.Framework.Console.MainLog.Instance.Verbose("Finished loading " + compiledscripts.Count.ToString() + " script(s)"); | ||
50 | } | ||
51 | |||
52 | public ScriptManager(OpenSim.Region.Scenes.Scene world) | ||
53 | { | ||
54 | scene = world; | ||
55 | |||
56 | // Default Engines | ||
57 | CSharpScriptEngine csharpCompiler = new CSharpScriptEngine(); | ||
58 | compilers.Add(csharpCompiler.FileExt(),csharpCompiler); | ||
59 | |||
60 | JScriptEngine jscriptCompiler = new JScriptEngine(); | ||
61 | compilers.Add(jscriptCompiler.FileExt(), jscriptCompiler); | ||
62 | |||
63 | JSharpScriptEngine jsharpCompiler = new JSharpScriptEngine(); | ||
64 | compilers.Add(jsharpCompiler.FileExt(), jsharpCompiler); | ||
65 | } | ||
66 | |||
67 | public void Compile(string filename) | ||
68 | { | ||
69 | foreach (KeyValuePair<string, IScriptCompiler> compiler in compilers) | ||
70 | { | ||
71 | if (filename.EndsWith(compiler.Key)) | ||
72 | { | ||
73 | LoadFromCompiler(compiler.Value.compile(filename)); | ||
74 | break; | ||
75 | } | ||
76 | } | ||
77 | } | ||
78 | |||
79 | public void RunScriptCmd(string[] args) | ||
80 | { | ||
81 | switch (args[0]) | ||
82 | { | ||
83 | case "load": | ||
84 | Compile(args[1]); | ||
85 | break; | ||
86 | |||
87 | default: | ||
88 | OpenSim.Framework.Console.MainLog.Instance.Error("Unknown script command"); | ||
89 | break; | ||
90 | } | ||
91 | } | ||
92 | } | ||
93 | |||
94 | interface IScriptCompiler | ||
95 | { | ||
96 | Dictionary<string,IScript> compile(string filename); | ||
97 | string FileExt(); | ||
98 | } | ||
99 | } | ||