diff options
Diffstat (limited to 'OpenSim/Region/Environment')
53 files changed, 9539 insertions, 9539 deletions
diff --git a/OpenSim/Region/Environment/EstateManager.cs b/OpenSim/Region/Environment/EstateManager.cs index de0b040..3742486 100644 --- a/OpenSim/Region/Environment/EstateManager.cs +++ b/OpenSim/Region/Environment/EstateManager.cs | |||
@@ -1,299 +1,299 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | using libsecondlife; | 31 | using libsecondlife; |
32 | using libsecondlife.Packets; | 32 | using libsecondlife.Packets; |
33 | using OpenSim.Framework.Console; | 33 | using OpenSim.Framework.Console; |
34 | using OpenSim.Framework.Interfaces; | 34 | using OpenSim.Framework.Interfaces; |
35 | using OpenSim.Framework.Types; | 35 | using OpenSim.Framework.Types; |
36 | using OpenSim.Region.Environment.Scenes; | 36 | using OpenSim.Region.Environment.Scenes; |
37 | using Avatar = OpenSim.Region.Environment.Scenes.ScenePresence; | 37 | using Avatar = OpenSim.Region.Environment.Scenes.ScenePresence; |
38 | 38 | ||
39 | 39 | ||
40 | namespace OpenSim.Region.Environment | 40 | namespace OpenSim.Region.Environment |
41 | { | 41 | { |
42 | 42 | ||
43 | /// <summary> | 43 | /// <summary> |
44 | /// Processes requests regarding estates. Refer to EstateSettings.cs in OpenSim.Framework. Types for all of the core settings | 44 | /// Processes requests regarding estates. Refer to EstateSettings.cs in OpenSim.Framework. Types for all of the core settings |
45 | /// </summary> | 45 | /// </summary> |
46 | public class EstateManager | 46 | public class EstateManager |
47 | { | 47 | { |
48 | private Scene m_world; | 48 | private Scene m_world; |
49 | private RegionInfo m_regInfo; | 49 | private RegionInfo m_regInfo; |
50 | 50 | ||
51 | public EstateManager(Scene world,RegionInfo reginfo) | 51 | public EstateManager(Scene world,RegionInfo reginfo) |
52 | { | 52 | { |
53 | m_world = world; //Estate settings found at world.m_regInfo.estateSettings | 53 | m_world = world; //Estate settings found at world.m_regInfo.estateSettings |
54 | m_regInfo = reginfo; | 54 | m_regInfo = reginfo; |
55 | } | 55 | } |
56 | 56 | ||
57 | private bool convertParamStringToBool(byte[] field) | 57 | private bool convertParamStringToBool(byte[] field) |
58 | { | 58 | { |
59 | string s = Helpers.FieldToUTF8String(field); | 59 | string s = Helpers.FieldToUTF8String(field); |
60 | if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true") | 60 | if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true") |
61 | { | 61 | { |
62 | return true; | 62 | return true; |
63 | } | 63 | } |
64 | return false; | 64 | return false; |
65 | } | 65 | } |
66 | 66 | ||
67 | public void handleEstateOwnerMessage(EstateOwnerMessagePacket packet, IClientAPI remote_client) | 67 | public void handleEstateOwnerMessage(EstateOwnerMessagePacket packet, IClientAPI remote_client) |
68 | { | 68 | { |
69 | if (remote_client.AgentId == m_regInfo.MasterAvatarAssignedUUID) | 69 | if (remote_client.AgentId == m_regInfo.MasterAvatarAssignedUUID) |
70 | { | 70 | { |
71 | switch (Helpers.FieldToUTF8String(packet.MethodData.Method)) | 71 | switch (Helpers.FieldToUTF8String(packet.MethodData.Method)) |
72 | { | 72 | { |
73 | case "getinfo": | 73 | case "getinfo": |
74 | this.sendRegionInfoPacketToAll(); | 74 | this.sendRegionInfoPacketToAll(); |
75 | 75 | ||
76 | break; | 76 | break; |
77 | case "setregioninfo": | 77 | case "setregioninfo": |
78 | if (packet.ParamList.Length != 9) | 78 | if (packet.ParamList.Length != 9) |
79 | { | 79 | { |
80 | MainLog.Instance.Error("EstateOwnerMessage: SetRegionInfo method has a ParamList of invalid length"); | 80 | MainLog.Instance.Error("EstateOwnerMessage: SetRegionInfo method has a ParamList of invalid length"); |
81 | } | 81 | } |
82 | else | 82 | else |
83 | { | 83 | { |
84 | m_regInfo.estateSettings.regionFlags = Simulator.RegionFlags.None; | 84 | m_regInfo.estateSettings.regionFlags = Simulator.RegionFlags.None; |
85 | 85 | ||
86 | if (convertParamStringToBool(packet.ParamList[0].Parameter)) | 86 | if (convertParamStringToBool(packet.ParamList[0].Parameter)) |
87 | { | 87 | { |
88 | m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.BlockTerraform; | 88 | m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.BlockTerraform; |
89 | } | 89 | } |
90 | 90 | ||
91 | if (convertParamStringToBool(packet.ParamList[1].Parameter)) | 91 | if (convertParamStringToBool(packet.ParamList[1].Parameter)) |
92 | { | 92 | { |
93 | m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.NoFly; | 93 | m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.NoFly; |
94 | } | 94 | } |
95 | 95 | ||
96 | if (convertParamStringToBool(packet.ParamList[2].Parameter)) | 96 | if (convertParamStringToBool(packet.ParamList[2].Parameter)) |
97 | { | 97 | { |
98 | m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.AllowDamage; | 98 | m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.AllowDamage; |
99 | } | 99 | } |
100 | 100 | ||
101 | if (convertParamStringToBool(packet.ParamList[3].Parameter) == false) | 101 | if (convertParamStringToBool(packet.ParamList[3].Parameter) == false) |
102 | { | 102 | { |
103 | m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.BlockLandResell; | 103 | m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.BlockLandResell; |
104 | } | 104 | } |
105 | 105 | ||
106 | 106 | ||
107 | int tempMaxAgents = Convert.ToInt16(Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[4].Parameter))); | 107 | int tempMaxAgents = Convert.ToInt16(Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[4].Parameter))); |
108 | m_regInfo.estateSettings.maxAgents = (byte)tempMaxAgents; | 108 | m_regInfo.estateSettings.maxAgents = (byte)tempMaxAgents; |
109 | 109 | ||
110 | float tempObjectBonusFactor = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter)); | 110 | float tempObjectBonusFactor = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter)); |
111 | m_regInfo.estateSettings.objectBonusFactor = tempObjectBonusFactor; | 111 | m_regInfo.estateSettings.objectBonusFactor = tempObjectBonusFactor; |
112 | 112 | ||
113 | int tempMatureLevel = Convert.ToInt16(Helpers.FieldToUTF8String(packet.ParamList[6].Parameter)); | 113 | int tempMatureLevel = Convert.ToInt16(Helpers.FieldToUTF8String(packet.ParamList[6].Parameter)); |
114 | m_regInfo.estateSettings.simAccess = (Simulator.SimAccess)tempMatureLevel; | 114 | m_regInfo.estateSettings.simAccess = (Simulator.SimAccess)tempMatureLevel; |
115 | 115 | ||
116 | 116 | ||
117 | if (convertParamStringToBool(packet.ParamList[7].Parameter)) | 117 | if (convertParamStringToBool(packet.ParamList[7].Parameter)) |
118 | { | 118 | { |
119 | m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.RestrictPushObject; | 119 | m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.RestrictPushObject; |
120 | } | 120 | } |
121 | 121 | ||
122 | if (convertParamStringToBool(packet.ParamList[8].Parameter)) | 122 | if (convertParamStringToBool(packet.ParamList[8].Parameter)) |
123 | { | 123 | { |
124 | m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.AllowParcelChanges; | 124 | m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.AllowParcelChanges; |
125 | } | 125 | } |
126 | 126 | ||
127 | sendRegionInfoPacketToAll(); | 127 | sendRegionInfoPacketToAll(); |
128 | 128 | ||
129 | } | 129 | } |
130 | break; | 130 | break; |
131 | case "texturebase": | 131 | case "texturebase": |
132 | foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList) | 132 | foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList) |
133 | { | 133 | { |
134 | string s = Helpers.FieldToUTF8String(block.Parameter); | 134 | string s = Helpers.FieldToUTF8String(block.Parameter); |
135 | string[] splitField = s.Split(' '); | 135 | string[] splitField = s.Split(' '); |
136 | if (splitField.Length == 2) | 136 | if (splitField.Length == 2) |
137 | { | 137 | { |
138 | LLUUID tempUUID = new LLUUID(splitField[1]); | 138 | LLUUID tempUUID = new LLUUID(splitField[1]); |
139 | switch (Convert.ToInt16(splitField[0])) | 139 | switch (Convert.ToInt16(splitField[0])) |
140 | { | 140 | { |
141 | case 0: | 141 | case 0: |
142 | m_regInfo.estateSettings.terrainBase0 = tempUUID; | 142 | m_regInfo.estateSettings.terrainBase0 = tempUUID; |
143 | break; | 143 | break; |
144 | case 1: | 144 | case 1: |
145 | m_regInfo.estateSettings.terrainBase1 = tempUUID; | 145 | m_regInfo.estateSettings.terrainBase1 = tempUUID; |
146 | break; | 146 | break; |
147 | case 2: | 147 | case 2: |
148 | m_regInfo.estateSettings.terrainBase2 = tempUUID; | 148 | m_regInfo.estateSettings.terrainBase2 = tempUUID; |
149 | break; | 149 | break; |
150 | case 3: | 150 | case 3: |
151 | m_regInfo.estateSettings.terrainBase3 = tempUUID; | 151 | m_regInfo.estateSettings.terrainBase3 = tempUUID; |
152 | break; | 152 | break; |
153 | } | 153 | } |
154 | } | 154 | } |
155 | } | 155 | } |
156 | break; | 156 | break; |
157 | case "texturedetail": | 157 | case "texturedetail": |
158 | foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList) | 158 | foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList) |
159 | { | 159 | { |
160 | 160 | ||
161 | string s = Helpers.FieldToUTF8String(block.Parameter); | 161 | string s = Helpers.FieldToUTF8String(block.Parameter); |
162 | string[] splitField = s.Split(' '); | 162 | string[] splitField = s.Split(' '); |
163 | if (splitField.Length == 2) | 163 | if (splitField.Length == 2) |
164 | { | 164 | { |
165 | LLUUID tempUUID = new LLUUID(splitField[1]); | 165 | LLUUID tempUUID = new LLUUID(splitField[1]); |
166 | switch (Convert.ToInt16(splitField[0])) | 166 | switch (Convert.ToInt16(splitField[0])) |
167 | { | 167 | { |
168 | case 0: | 168 | case 0: |
169 | m_regInfo.estateSettings.terrainDetail0 = tempUUID; | 169 | m_regInfo.estateSettings.terrainDetail0 = tempUUID; |
170 | break; | 170 | break; |
171 | case 1: | 171 | case 1: |
172 | m_regInfo.estateSettings.terrainDetail1 = tempUUID; | 172 | m_regInfo.estateSettings.terrainDetail1 = tempUUID; |
173 | break; | 173 | break; |
174 | case 2: | 174 | case 2: |
175 | m_regInfo.estateSettings.terrainDetail2 = tempUUID; | 175 | m_regInfo.estateSettings.terrainDetail2 = tempUUID; |
176 | break; | 176 | break; |
177 | case 3: | 177 | case 3: |
178 | m_regInfo.estateSettings.terrainDetail3 = tempUUID; | 178 | m_regInfo.estateSettings.terrainDetail3 = tempUUID; |
179 | break; | 179 | break; |
180 | } | 180 | } |
181 | } | 181 | } |
182 | } | 182 | } |
183 | break; | 183 | break; |
184 | case "textureheights": | 184 | case "textureheights": |
185 | foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList) | 185 | foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList) |
186 | { | 186 | { |
187 | 187 | ||
188 | string s = Helpers.FieldToUTF8String(block.Parameter); | 188 | string s = Helpers.FieldToUTF8String(block.Parameter); |
189 | string[] splitField = s.Split(' '); | 189 | string[] splitField = s.Split(' '); |
190 | if (splitField.Length == 3) | 190 | if (splitField.Length == 3) |
191 | { | 191 | { |
192 | 192 | ||
193 | float tempHeightLow = (float)Convert.ToDecimal(splitField[1]); | 193 | float tempHeightLow = (float)Convert.ToDecimal(splitField[1]); |
194 | float tempHeightHigh = (float)Convert.ToDecimal(splitField[2]); | 194 | float tempHeightHigh = (float)Convert.ToDecimal(splitField[2]); |
195 | 195 | ||
196 | switch (Convert.ToInt16(splitField[0])) | 196 | switch (Convert.ToInt16(splitField[0])) |
197 | { | 197 | { |
198 | case 0: | 198 | case 0: |
199 | m_regInfo.estateSettings.terrainStartHeight0 = tempHeightLow; | 199 | m_regInfo.estateSettings.terrainStartHeight0 = tempHeightLow; |
200 | m_regInfo.estateSettings.terrainHeightRange0 = tempHeightHigh; | 200 | m_regInfo.estateSettings.terrainHeightRange0 = tempHeightHigh; |
201 | break; | 201 | break; |
202 | case 1: | 202 | case 1: |
203 | m_regInfo.estateSettings.terrainStartHeight1 = tempHeightLow; | 203 | m_regInfo.estateSettings.terrainStartHeight1 = tempHeightLow; |
204 | m_regInfo.estateSettings.terrainHeightRange1 = tempHeightHigh; | 204 | m_regInfo.estateSettings.terrainHeightRange1 = tempHeightHigh; |
205 | break; | 205 | break; |
206 | case 2: | 206 | case 2: |
207 | m_regInfo.estateSettings.terrainStartHeight2 = tempHeightLow; | 207 | m_regInfo.estateSettings.terrainStartHeight2 = tempHeightLow; |
208 | m_regInfo.estateSettings.terrainHeightRange2 = tempHeightHigh; | 208 | m_regInfo.estateSettings.terrainHeightRange2 = tempHeightHigh; |
209 | break; | 209 | break; |
210 | case 3: | 210 | case 3: |
211 | m_regInfo.estateSettings.terrainStartHeight3 = tempHeightLow; | 211 | m_regInfo.estateSettings.terrainStartHeight3 = tempHeightLow; |
212 | m_regInfo.estateSettings.terrainHeightRange3 = tempHeightHigh; | 212 | m_regInfo.estateSettings.terrainHeightRange3 = tempHeightHigh; |
213 | break; | 213 | break; |
214 | } | 214 | } |
215 | } | 215 | } |
216 | } | 216 | } |
217 | break; | 217 | break; |
218 | case "texturecommit": | 218 | case "texturecommit": |
219 | sendRegionHandshakeToAll(); | 219 | sendRegionHandshakeToAll(); |
220 | break; | 220 | break; |
221 | case "setregionterrain": | 221 | case "setregionterrain": |
222 | if (packet.ParamList.Length != 9) | 222 | if (packet.ParamList.Length != 9) |
223 | { | 223 | { |
224 | MainLog.Instance.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length"); | 224 | MainLog.Instance.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length"); |
225 | } | 225 | } |
226 | else | 226 | else |
227 | { | 227 | { |
228 | m_regInfo.estateSettings.waterHeight = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[0].Parameter)); | 228 | m_regInfo.estateSettings.waterHeight = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[0].Parameter)); |
229 | m_regInfo.estateSettings.terrainRaiseLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter)); | 229 | m_regInfo.estateSettings.terrainRaiseLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter)); |
230 | m_regInfo.estateSettings.terrainLowerLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter)); | 230 | m_regInfo.estateSettings.terrainLowerLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter)); |
231 | m_regInfo.estateSettings.useFixedSun = this.convertParamStringToBool(packet.ParamList[4].Parameter); | 231 | m_regInfo.estateSettings.useFixedSun = this.convertParamStringToBool(packet.ParamList[4].Parameter); |
232 | m_regInfo.estateSettings.sunHour = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter)); | 232 | m_regInfo.estateSettings.sunHour = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter)); |
233 | 233 | ||
234 | sendRegionInfoPacketToAll(); | 234 | sendRegionInfoPacketToAll(); |
235 | } | 235 | } |
236 | break; | 236 | break; |
237 | default: | 237 | default: |
238 | MainLog.Instance.Error("EstateOwnerMessage: Unknown method requested\n" + packet.ToString()); | 238 | MainLog.Instance.Error("EstateOwnerMessage: Unknown method requested\n" + packet.ToString()); |
239 | break; | 239 | break; |
240 | } | 240 | } |
241 | } | 241 | } |
242 | } | 242 | } |
243 | 243 | ||
244 | public void sendRegionInfoPacketToAll() | 244 | public void sendRegionInfoPacketToAll() |
245 | { | 245 | { |
246 | List<Avatar> avatars = m_world.RequestAvatarList(); | 246 | List<Avatar> avatars = m_world.RequestAvatarList(); |
247 | 247 | ||
248 | for (int i = 0; i < avatars.Count; i++) | 248 | for (int i = 0; i < avatars.Count; i++) |
249 | { | 249 | { |
250 | this.sendRegionInfoPacket(avatars[i].ControllingClient); | 250 | this.sendRegionInfoPacket(avatars[i].ControllingClient); |
251 | } | 251 | } |
252 | } | 252 | } |
253 | 253 | ||
254 | public void sendRegionHandshakeToAll() | 254 | public void sendRegionHandshakeToAll() |
255 | { | 255 | { |
256 | List<Avatar> avatars = m_world.RequestAvatarList(); | 256 | List<Avatar> avatars = m_world.RequestAvatarList(); |
257 | 257 | ||
258 | for (int i = 0; i < avatars.Count; i++) | 258 | for (int i = 0; i < avatars.Count; i++) |
259 | { | 259 | { |
260 | this.sendRegionHandshake(avatars[i].ControllingClient); | 260 | this.sendRegionHandshake(avatars[i].ControllingClient); |
261 | } | 261 | } |
262 | } | 262 | } |
263 | 263 | ||
264 | public void sendRegionInfoPacket(IClientAPI remote_client) | 264 | public void sendRegionInfoPacket(IClientAPI remote_client) |
265 | { | 265 | { |
266 | Encoding _enc = Encoding.ASCII; | 266 | Encoding _enc = Encoding.ASCII; |
267 | 267 | ||
268 | AgentCircuitData circuitData = remote_client.RequestClientInfo(); | 268 | AgentCircuitData circuitData = remote_client.RequestClientInfo(); |
269 | 269 | ||
270 | RegionInfoPacket regionInfoPacket = new RegionInfoPacket(); | 270 | RegionInfoPacket regionInfoPacket = new RegionInfoPacket(); |
271 | regionInfoPacket.AgentData.AgentID = circuitData.AgentID; | 271 | regionInfoPacket.AgentData.AgentID = circuitData.AgentID; |
272 | regionInfoPacket.AgentData.SessionID = circuitData.SessionID; | 272 | regionInfoPacket.AgentData.SessionID = circuitData.SessionID; |
273 | regionInfoPacket.RegionInfo.BillableFactor = m_regInfo.estateSettings.billableFactor; | 273 | regionInfoPacket.RegionInfo.BillableFactor = m_regInfo.estateSettings.billableFactor; |
274 | regionInfoPacket.RegionInfo.EstateID = m_regInfo.estateSettings.estateID; | 274 | regionInfoPacket.RegionInfo.EstateID = m_regInfo.estateSettings.estateID; |
275 | regionInfoPacket.RegionInfo.MaxAgents = m_regInfo.estateSettings.maxAgents; | 275 | regionInfoPacket.RegionInfo.MaxAgents = m_regInfo.estateSettings.maxAgents; |
276 | regionInfoPacket.RegionInfo.ObjectBonusFactor = m_regInfo.estateSettings.objectBonusFactor; | 276 | regionInfoPacket.RegionInfo.ObjectBonusFactor = m_regInfo.estateSettings.objectBonusFactor; |
277 | regionInfoPacket.RegionInfo.ParentEstateID = m_regInfo.estateSettings.parentEstateID; | 277 | regionInfoPacket.RegionInfo.ParentEstateID = m_regInfo.estateSettings.parentEstateID; |
278 | regionInfoPacket.RegionInfo.PricePerMeter = m_regInfo.estateSettings.pricePerMeter; | 278 | regionInfoPacket.RegionInfo.PricePerMeter = m_regInfo.estateSettings.pricePerMeter; |
279 | regionInfoPacket.RegionInfo.RedirectGridX = m_regInfo.estateSettings.redirectGridX; | 279 | regionInfoPacket.RegionInfo.RedirectGridX = m_regInfo.estateSettings.redirectGridX; |
280 | regionInfoPacket.RegionInfo.RedirectGridY = m_regInfo.estateSettings.redirectGridY; | 280 | regionInfoPacket.RegionInfo.RedirectGridY = m_regInfo.estateSettings.redirectGridY; |
281 | regionInfoPacket.RegionInfo.RegionFlags = (uint)m_regInfo.estateSettings.regionFlags; | 281 | regionInfoPacket.RegionInfo.RegionFlags = (uint)m_regInfo.estateSettings.regionFlags; |
282 | regionInfoPacket.RegionInfo.SimAccess = (byte)m_regInfo.estateSettings.simAccess; | 282 | regionInfoPacket.RegionInfo.SimAccess = (byte)m_regInfo.estateSettings.simAccess; |
283 | regionInfoPacket.RegionInfo.SimName = _enc.GetBytes( m_regInfo.RegionName); | 283 | regionInfoPacket.RegionInfo.SimName = _enc.GetBytes( m_regInfo.RegionName); |
284 | regionInfoPacket.RegionInfo.SunHour = m_regInfo.estateSettings.sunHour; | 284 | regionInfoPacket.RegionInfo.SunHour = m_regInfo.estateSettings.sunHour; |
285 | regionInfoPacket.RegionInfo.TerrainLowerLimit = m_regInfo.estateSettings.terrainLowerLimit; | 285 | regionInfoPacket.RegionInfo.TerrainLowerLimit = m_regInfo.estateSettings.terrainLowerLimit; |
286 | regionInfoPacket.RegionInfo.TerrainRaiseLimit = m_regInfo.estateSettings.terrainRaiseLimit; | 286 | regionInfoPacket.RegionInfo.TerrainRaiseLimit = m_regInfo.estateSettings.terrainRaiseLimit; |
287 | regionInfoPacket.RegionInfo.UseEstateSun = !m_regInfo.estateSettings.useFixedSun; | 287 | regionInfoPacket.RegionInfo.UseEstateSun = !m_regInfo.estateSettings.useFixedSun; |
288 | regionInfoPacket.RegionInfo.WaterHeight = m_regInfo.estateSettings.waterHeight; | 288 | regionInfoPacket.RegionInfo.WaterHeight = m_regInfo.estateSettings.waterHeight; |
289 | 289 | ||
290 | remote_client.OutPacket(regionInfoPacket); | 290 | remote_client.OutPacket(regionInfoPacket); |
291 | } | 291 | } |
292 | 292 | ||
293 | public void sendRegionHandshake(IClientAPI remoteClient) | 293 | public void sendRegionHandshake(IClientAPI remoteClient) |
294 | { | 294 | { |
295 | remoteClient.SendRegionHandshake(m_regInfo); | 295 | remoteClient.SendRegionHandshake(m_regInfo); |
296 | } | 296 | } |
297 | 297 | ||
298 | } | 298 | } |
299 | } | 299 | } |
diff --git a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs index c068866..6ee57a5 100644 --- a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs +++ b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs | |||
@@ -1,63 +1,63 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using libsecondlife; | 29 | using libsecondlife; |
30 | 30 | ||
31 | using OpenSim.Framework.Types; | 31 | using OpenSim.Framework.Types; |
32 | using OpenSim.Region; | 32 | using OpenSim.Region; |
33 | using OpenSim.Region.Environment; | 33 | using OpenSim.Region.Environment; |
34 | using OpenSim.Region.Environment.Scenes; | 34 | using OpenSim.Region.Environment.Scenes; |
35 | 35 | ||
36 | using System.Collections.Generic; | 36 | using System.Collections.Generic; |
37 | 37 | ||
38 | namespace OpenSim.Region.Interfaces | 38 | namespace OpenSim.Region.Interfaces |
39 | { | 39 | { |
40 | public interface IRegionDataStore | 40 | public interface IRegionDataStore |
41 | { | 41 | { |
42 | /// <summary> | 42 | /// <summary> |
43 | /// Initialises the data storage engine | 43 | /// Initialises the data storage engine |
44 | /// </summary> | 44 | /// </summary> |
45 | /// <param name="filename">The file to save the database to (may not be applicable)</param> | 45 | /// <param name="filename">The file to save the database to (may not be applicable)</param> |
46 | /// <param name="dbname">The name of the database to store to (may not be applicable)</param> | 46 | /// <param name="dbname">The name of the database to store to (may not be applicable)</param> |
47 | void Initialise(string filename, string dbname); | 47 | void Initialise(string filename, string dbname); |
48 | 48 | ||
49 | void StoreObject(SceneObject obj); | 49 | void StoreObject(SceneObject obj); |
50 | void RemoveObject(LLUUID uuid); | 50 | void RemoveObject(LLUUID uuid); |
51 | 51 | ||
52 | List<SceneObject> LoadObjects(); | 52 | List<SceneObject> LoadObjects(); |
53 | 53 | ||
54 | void StoreTerrain(double[,] terrain); | 54 | void StoreTerrain(double[,] terrain); |
55 | double[,] LoadTerrain(); | 55 | double[,] LoadTerrain(); |
56 | 56 | ||
57 | void StoreParcel(OpenSim.Region.Environment.Parcel Parcel); | 57 | void StoreParcel(OpenSim.Region.Environment.Parcel Parcel); |
58 | void RemoveParcel(uint ID); | 58 | void RemoveParcel(uint ID); |
59 | List<OpenSim.Region.Environment.Parcel> LoadParcels(); | 59 | List<OpenSim.Region.Environment.Parcel> LoadParcels(); |
60 | 60 | ||
61 | void Shutdown(); | 61 | void Shutdown(); |
62 | } | 62 | } |
63 | } \ No newline at end of file | 63 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/ParcelManager.cs b/OpenSim/Region/Environment/ParcelManager.cs index 31b9b1d..fbff556 100644 --- a/OpenSim/Region/Environment/ParcelManager.cs +++ b/OpenSim/Region/Environment/ParcelManager.cs | |||
@@ -1,1206 +1,1206 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using libsecondlife; | 30 | using libsecondlife; |
31 | using libsecondlife.Packets; | 31 | using libsecondlife.Packets; |
32 | using OpenSim.Framework.Interfaces; | 32 | using OpenSim.Framework.Interfaces; |
33 | using OpenSim.Framework.Types; | 33 | using OpenSim.Framework.Types; |
34 | using OpenSim.Region.Environment.Scenes; | 34 | using OpenSim.Region.Environment.Scenes; |
35 | using Avatar = OpenSim.Region.Environment.Scenes.ScenePresence; | 35 | using Avatar = OpenSim.Region.Environment.Scenes.ScenePresence; |
36 | using System.IO; | 36 | using System.IO; |
37 | 37 | ||
38 | namespace OpenSim.Region.Environment | 38 | namespace OpenSim.Region.Environment |
39 | { | 39 | { |
40 | 40 | ||
41 | 41 | ||
42 | #region ParcelManager Class | 42 | #region ParcelManager Class |
43 | /// <summary> | 43 | /// <summary> |
44 | /// Handles Parcel objects and operations requiring information from other Parcel objects (divide, join, etc) | 44 | /// Handles Parcel objects and operations requiring information from other Parcel objects (divide, join, etc) |
45 | /// </summary> | 45 | /// </summary> |
46 | public class ParcelManager : ILocalStorageParcelReceiver | 46 | public class ParcelManager : ILocalStorageParcelReceiver |
47 | { | 47 | { |
48 | 48 | ||
49 | #region Constants | 49 | #region Constants |
50 | //Parcel types set with flags in ParcelOverlay. | 50 | //Parcel types set with flags in ParcelOverlay. |
51 | //Only one of these can be used. | 51 | //Only one of these can be used. |
52 | public const byte PARCEL_TYPE_PUBLIC = (byte)0; //Equals 00000000 | 52 | public const byte PARCEL_TYPE_PUBLIC = (byte)0; //Equals 00000000 |
53 | public const byte PARCEL_TYPE_OWNED_BY_OTHER = (byte)1; //Equals 00000001 | 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 | 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 | 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 | 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 | 57 | public const byte PARCEL_TYPE_IS_BEING_AUCTIONED = (byte)5; //Equals 00000101 |
58 | 58 | ||
59 | 59 | ||
60 | //Flags that when set, a border on the given side will be placed | 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) | 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 | 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 | 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 | 64 | public const byte PARCEL_FLAG_PROPERTY_BORDER_SOUTH = (byte)128; //Equals 10000000 |
65 | 65 | ||
66 | //RequestResults (I think these are right, they seem to work): | 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 | 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 | 68 | public const int PARCEL_RESULT_MULTIPLE_PARCELS = 1; // The request they made contained more than one parcel |
69 | 69 | ||
70 | //ParcelSelectObjects | 70 | //ParcelSelectObjects |
71 | public const int PARCEL_SELECT_OBJECTS_OWNER = 2; | 71 | public const int PARCEL_SELECT_OBJECTS_OWNER = 2; |
72 | public const int PARCEL_SELECT_OBJECTS_GROUP = 4; | 72 | public const int PARCEL_SELECT_OBJECTS_GROUP = 4; |
73 | public const int PARCEL_SELECT_OBJECTS_OTHER = 8; | 73 | public const int PARCEL_SELECT_OBJECTS_OTHER = 8; |
74 | 74 | ||
75 | 75 | ||
76 | //These are other constants. Yay! | 76 | //These are other constants. Yay! |
77 | public const int START_PARCEL_LOCAL_ID = 1; | 77 | public const int START_PARCEL_LOCAL_ID = 1; |
78 | #endregion | 78 | #endregion |
79 | 79 | ||
80 | #region Member Variables | 80 | #region Member Variables |
81 | public Dictionary<int, Parcel> parcelList = new Dictionary<int, Parcel>(); | 81 | public Dictionary<int, Parcel> parcelList = new Dictionary<int, Parcel>(); |
82 | private int lastParcelLocalID = START_PARCEL_LOCAL_ID - 1; | 82 | private int lastParcelLocalID = START_PARCEL_LOCAL_ID - 1; |
83 | private int[,] parcelIDList = new int[64, 64]; | 83 | private int[,] parcelIDList = new int[64, 64]; |
84 | 84 | ||
85 | /// <summary> | 85 | /// <summary> |
86 | /// Set to true when a prim is moved, created, added. Performs a prim count update | 86 | /// Set to true when a prim is moved, created, added. Performs a prim count update |
87 | /// </summary> | 87 | /// </summary> |
88 | public bool parcelPrimCountTainted = false; | 88 | public bool parcelPrimCountTainted = false; |
89 | 89 | ||
90 | private Scene m_world; | 90 | private Scene m_world; |
91 | private RegionInfo m_regInfo; | 91 | private RegionInfo m_regInfo; |
92 | 92 | ||
93 | #endregion | 93 | #endregion |
94 | 94 | ||
95 | #region Constructors | 95 | #region Constructors |
96 | public ParcelManager(Scene world, RegionInfo reginfo) | 96 | public ParcelManager(Scene world, RegionInfo reginfo) |
97 | { | 97 | { |
98 | 98 | ||
99 | m_world = world; | 99 | m_world = world; |
100 | m_regInfo = reginfo; | 100 | m_regInfo = reginfo; |
101 | parcelIDList.Initialize(); | 101 | parcelIDList.Initialize(); |
102 | 102 | ||
103 | } | 103 | } |
104 | #endregion | 104 | #endregion |
105 | 105 | ||
106 | #region Member Functions | 106 | #region Member Functions |
107 | 107 | ||
108 | #region Parcel From Storage Functions | 108 | #region Parcel From Storage Functions |
109 | public void ParcelFromStorage(ParcelData data) | 109 | public void ParcelFromStorage(ParcelData data) |
110 | { | 110 | { |
111 | Parcel new_parcel = new Parcel(data.ownerID, data.isGroupOwned, m_world); | 111 | Parcel new_parcel = new Parcel(data.ownerID, data.isGroupOwned, m_world); |
112 | new_parcel.parcelData = data.Copy(); | 112 | new_parcel.parcelData = data.Copy(); |
113 | new_parcel.setParcelBitmapFromByteArray(); | 113 | new_parcel.setParcelBitmapFromByteArray(); |
114 | addParcel(new_parcel); | 114 | addParcel(new_parcel); |
115 | 115 | ||
116 | } | 116 | } |
117 | 117 | ||
118 | public void NoParcelDataFromStorage() | 118 | public void NoParcelDataFromStorage() |
119 | { | 119 | { |
120 | resetSimParcels(); | 120 | resetSimParcels(); |
121 | } | 121 | } |
122 | #endregion | 122 | #endregion |
123 | 123 | ||
124 | #region Parcel Add/Remove/Get/Create | 124 | #region Parcel Add/Remove/Get/Create |
125 | /// <summary> | 125 | /// <summary> |
126 | /// Creates a basic Parcel object without an owner (a zeroed key) | 126 | /// Creates a basic Parcel object without an owner (a zeroed key) |
127 | /// </summary> | 127 | /// </summary> |
128 | /// <returns></returns> | 128 | /// <returns></returns> |
129 | public Parcel createBaseParcel() | 129 | public Parcel createBaseParcel() |
130 | { | 130 | { |
131 | return new Parcel(new LLUUID(), false, m_world); | 131 | return new Parcel(new LLUUID(), false, m_world); |
132 | } | 132 | } |
133 | 133 | ||
134 | /// <summary> | 134 | /// <summary> |
135 | /// Adds a parcel to the stored list and adds them to the parcelIDList to what they own | 135 | /// Adds a parcel to the stored list and adds them to the parcelIDList to what they own |
136 | /// </summary> | 136 | /// </summary> |
137 | /// <param name="new_parcel">The parcel being added</param> | 137 | /// <param name="new_parcel">The parcel being added</param> |
138 | public Parcel addParcel(Parcel new_parcel) | 138 | public Parcel addParcel(Parcel new_parcel) |
139 | { | 139 | { |
140 | lastParcelLocalID++; | 140 | lastParcelLocalID++; |
141 | new_parcel.parcelData.localID = lastParcelLocalID; | 141 | new_parcel.parcelData.localID = lastParcelLocalID; |
142 | parcelList.Add(lastParcelLocalID, new_parcel.Copy()); | 142 | parcelList.Add(lastParcelLocalID, new_parcel.Copy()); |
143 | 143 | ||
144 | 144 | ||
145 | bool[,] parcelBitmap = new_parcel.getParcelBitmap(); | 145 | bool[,] parcelBitmap = new_parcel.getParcelBitmap(); |
146 | int x, y; | 146 | int x, y; |
147 | for (x = 0; x < 64; x++) | 147 | for (x = 0; x < 64; x++) |
148 | { | 148 | { |
149 | for (y = 0; y < 64; y++) | 149 | for (y = 0; y < 64; y++) |
150 | { | 150 | { |
151 | if (parcelBitmap[x, y]) | 151 | if (parcelBitmap[x, y]) |
152 | { | 152 | { |
153 | parcelIDList[x, y] = lastParcelLocalID; | 153 | parcelIDList[x, y] = lastParcelLocalID; |
154 | } | 154 | } |
155 | } | 155 | } |
156 | } | 156 | } |
157 | parcelList[lastParcelLocalID].forceUpdateParcelInfo(); | 157 | parcelList[lastParcelLocalID].forceUpdateParcelInfo(); |
158 | 158 | ||
159 | return new_parcel; | 159 | return new_parcel; |
160 | 160 | ||
161 | } | 161 | } |
162 | /// <summary> | 162 | /// <summary> |
163 | /// Removes a parcel from the list. Will not remove if local_id is still owning an area in parcelIDList | 163 | /// Removes a parcel from the list. Will not remove if local_id is still owning an area in parcelIDList |
164 | /// </summary> | 164 | /// </summary> |
165 | /// <param name="local_id">Parcel.localID of the parcel to remove.</param> | 165 | /// <param name="local_id">Parcel.localID of the parcel to remove.</param> |
166 | public void removeParcel(int local_id) | 166 | public void removeParcel(int local_id) |
167 | { | 167 | { |
168 | int x, y; | 168 | int x, y; |
169 | for (x = 0; x < 64; x++) | 169 | for (x = 0; x < 64; x++) |
170 | { | 170 | { |
171 | for (y = 0; y < 64; y++) | 171 | for (y = 0; y < 64; y++) |
172 | { | 172 | { |
173 | if (parcelIDList[x, y] == local_id) | 173 | if (parcelIDList[x, y] == local_id) |
174 | { | 174 | { |
175 | throw new Exception("Could not remove parcel. Still being used at " + x + ", " + y); | 175 | throw new Exception("Could not remove parcel. Still being used at " + x + ", " + y); |
176 | } | 176 | } |
177 | } | 177 | } |
178 | } | 178 | } |
179 | m_world.localStorage.RemoveParcel(parcelList[local_id].parcelData); | 179 | m_world.localStorage.RemoveParcel(parcelList[local_id].parcelData); |
180 | parcelList.Remove(local_id); | 180 | parcelList.Remove(local_id); |
181 | } | 181 | } |
182 | 182 | ||
183 | private void performFinalParcelJoin(Parcel master, Parcel slave) | 183 | private void performFinalParcelJoin(Parcel master, Parcel slave) |
184 | { | 184 | { |
185 | int x, y; | 185 | int x, y; |
186 | bool[,] parcelBitmapSlave = slave.getParcelBitmap(); | 186 | bool[,] parcelBitmapSlave = slave.getParcelBitmap(); |
187 | for (x = 0; x < 64; x++) | 187 | for (x = 0; x < 64; x++) |
188 | { | 188 | { |
189 | for (y = 0; y < 64; y++) | 189 | for (y = 0; y < 64; y++) |
190 | { | 190 | { |
191 | if (parcelBitmapSlave[x, y]) | 191 | if (parcelBitmapSlave[x, y]) |
192 | { | 192 | { |
193 | parcelIDList[x, y] = master.parcelData.localID; | 193 | parcelIDList[x, y] = master.parcelData.localID; |
194 | } | 194 | } |
195 | } | 195 | } |
196 | } | 196 | } |
197 | removeParcel(slave.parcelData.localID); | 197 | removeParcel(slave.parcelData.localID); |
198 | } | 198 | } |
199 | /// <summary> | 199 | /// <summary> |
200 | /// Get the parcel at the specified point | 200 | /// Get the parcel at the specified point |
201 | /// </summary> | 201 | /// </summary> |
202 | /// <param name="x">Value between 0 - 256 on the x axis of the point</param> | 202 | /// <param name="x">Value between 0 - 256 on the x axis of the point</param> |
203 | /// <param name="y">Value between 0 - 256 on the y axis of the point</param> | 203 | /// <param name="y">Value between 0 - 256 on the y axis of the point</param> |
204 | /// <returns>Parcel at the point supplied</returns> | 204 | /// <returns>Parcel at the point supplied</returns> |
205 | public Parcel getParcel(float x_float, float y_float) | 205 | public Parcel getParcel(float x_float, float y_float) |
206 | { | 206 | { |
207 | int x = Convert.ToInt32(Math.Floor(Convert.ToDecimal(x_float) / Convert.ToDecimal(4.0))); | 207 | int x = Convert.ToInt32(Math.Floor(Convert.ToDecimal(x_float) / Convert.ToDecimal(4.0))); |
208 | int y = Convert.ToInt32(Math.Floor(Convert.ToDecimal(y_float) / Convert.ToDecimal(4.0))); | 208 | int y = Convert.ToInt32(Math.Floor(Convert.ToDecimal(y_float) / Convert.ToDecimal(4.0))); |
209 | 209 | ||
210 | if (x > 63 || y > 63 || x < 0 || y < 0) | 210 | if (x > 63 || y > 63 || x < 0 || y < 0) |
211 | { | 211 | { |
212 | throw new Exception("Error: Parcel not found at point " + x + ", " + y); | 212 | throw new Exception("Error: Parcel not found at point " + x + ", " + y); |
213 | } | 213 | } |
214 | else | 214 | else |
215 | { | 215 | { |
216 | // Console.WriteLine("Point (" + x + ", " + y + ") determined from point (" + x_float + ", " + y_float + ")"); | 216 | // Console.WriteLine("Point (" + x + ", " + y + ") determined from point (" + x_float + ", " + y_float + ")"); |
217 | return parcelList[parcelIDList[x, y]]; | 217 | return parcelList[parcelIDList[x, y]]; |
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | public Parcel getParcel(int x, int y) | 221 | public Parcel getParcel(int x, int y) |
222 | { | 222 | { |
223 | if (x > 256 || y > 256 || x < 0 || y < 0) | 223 | if (x > 256 || y > 256 || x < 0 || y < 0) |
224 | { | 224 | { |
225 | throw new Exception("Error: Parcel not found at point " + x + ", " + y); | 225 | throw new Exception("Error: Parcel not found at point " + x + ", " + y); |
226 | } | 226 | } |
227 | else | 227 | else |
228 | { | 228 | { |
229 | return parcelList[parcelIDList[x / 4, y / 4]]; | 229 | return parcelList[parcelIDList[x / 4, y / 4]]; |
230 | } | 230 | } |
231 | } | 231 | } |
232 | #endregion | 232 | #endregion |
233 | 233 | ||
234 | #region Parcel Modification | 234 | #region Parcel Modification |
235 | /// <summary> | 235 | /// <summary> |
236 | /// Subdivides a parcel | 236 | /// Subdivides a parcel |
237 | /// </summary> | 237 | /// </summary> |
238 | /// <param name="start_x">West Point</param> | 238 | /// <param name="start_x">West Point</param> |
239 | /// <param name="start_y">South Point</param> | 239 | /// <param name="start_y">South Point</param> |
240 | /// <param name="end_x">East Point</param> | 240 | /// <param name="end_x">East Point</param> |
241 | /// <param name="end_y">North Point</param> | 241 | /// <param name="end_y">North Point</param> |
242 | /// <param name="attempting_user_id">LLUUID of user who is trying to subdivide</param> | 242 | /// <param name="attempting_user_id">LLUUID of user who is trying to subdivide</param> |
243 | /// <returns>Returns true if successful</returns> | 243 | /// <returns>Returns true if successful</returns> |
244 | private bool subdivide(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id) | 244 | private bool subdivide(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id) |
245 | { | 245 | { |
246 | 246 | ||
247 | //First, lets loop through the points and make sure they are all in the same parcel | 247 | //First, lets loop through the points and make sure they are all in the same parcel |
248 | //Get the parcel at start | 248 | //Get the parcel at start |
249 | Parcel startParcel = getParcel(start_x, start_y); | 249 | Parcel startParcel = getParcel(start_x, start_y); |
250 | if (startParcel == null) return false; //No such parcel at the beginning | 250 | if (startParcel == null) return false; //No such parcel at the beginning |
251 | 251 | ||
252 | //Loop through the points | 252 | //Loop through the points |
253 | try | 253 | try |
254 | { | 254 | { |
255 | int totalX = end_x - start_x; | 255 | int totalX = end_x - start_x; |
256 | int totalY = end_y - start_y; | 256 | int totalY = end_y - start_y; |
257 | int x, y; | 257 | int x, y; |
258 | for (y = 0; y < totalY; y++) | 258 | for (y = 0; y < totalY; y++) |
259 | { | 259 | { |
260 | for (x = 0; x < totalX; x++) | 260 | for (x = 0; x < totalX; x++) |
261 | { | 261 | { |
262 | Parcel tempParcel = getParcel(start_x + x, start_y + y); | 262 | Parcel tempParcel = getParcel(start_x + x, start_y + y); |
263 | if (tempParcel == null) return false; //No such parcel at that point | 263 | if (tempParcel == null) return false; //No such parcel at that point |
264 | if (tempParcel != startParcel) return false; //Subdividing over 2 parcels; no-no | 264 | if (tempParcel != startParcel) return false; //Subdividing over 2 parcels; no-no |
265 | } | 265 | } |
266 | } | 266 | } |
267 | } | 267 | } |
268 | catch (Exception) | 268 | catch (Exception) |
269 | { | 269 | { |
270 | return false; //Exception. For now, lets skip subdivision | 270 | return false; //Exception. For now, lets skip subdivision |
271 | } | 271 | } |
272 | 272 | ||
273 | //If we are still here, then they are subdividing within one parcel | 273 | //If we are still here, then they are subdividing within one parcel |
274 | //Check owner | 274 | //Check owner |
275 | if (startParcel.parcelData.ownerID != attempting_user_id) | 275 | if (startParcel.parcelData.ownerID != attempting_user_id) |
276 | { | 276 | { |
277 | return false; //They cant do this! | 277 | return false; //They cant do this! |
278 | } | 278 | } |
279 | 279 | ||
280 | //Lets create a new parcel with bitmap activated at that point (keeping the old parcels info) | 280 | //Lets create a new parcel with bitmap activated at that point (keeping the old parcels info) |
281 | Parcel newParcel = startParcel.Copy(); | 281 | Parcel newParcel = startParcel.Copy(); |
282 | newParcel.parcelData.parcelName = "Subdivision of " + newParcel.parcelData.parcelName; | 282 | newParcel.parcelData.parcelName = "Subdivision of " + newParcel.parcelData.parcelName; |
283 | newParcel.parcelData.globalID = LLUUID.Random(); | 283 | newParcel.parcelData.globalID = LLUUID.Random(); |
284 | 284 | ||
285 | newParcel.setParcelBitmap(Parcel.getSquareParcelBitmap(start_x, start_y, end_x, end_y)); | 285 | newParcel.setParcelBitmap(Parcel.getSquareParcelBitmap(start_x, start_y, end_x, end_y)); |
286 | 286 | ||
287 | //Now, lets set the subdivision area of the original to false | 287 | //Now, lets set the subdivision area of the original to false |
288 | int startParcelIndex = startParcel.parcelData.localID; | 288 | int startParcelIndex = startParcel.parcelData.localID; |
289 | parcelList[startParcelIndex].setParcelBitmap(Parcel.modifyParcelBitmapSquare(startParcel.getParcelBitmap(), start_x, start_y, end_x, end_y, false)); | 289 | parcelList[startParcelIndex].setParcelBitmap(Parcel.modifyParcelBitmapSquare(startParcel.getParcelBitmap(), start_x, start_y, end_x, end_y, false)); |
290 | parcelList[startParcelIndex].forceUpdateParcelInfo(); | 290 | parcelList[startParcelIndex].forceUpdateParcelInfo(); |
291 | 291 | ||
292 | 292 | ||
293 | this.setPrimsTainted(); | 293 | this.setPrimsTainted(); |
294 | 294 | ||
295 | //Now add the new parcel | 295 | //Now add the new parcel |
296 | Parcel result = addParcel(newParcel); | 296 | Parcel result = addParcel(newParcel); |
297 | result.sendParcelUpdateToAvatarsOverMe(); | 297 | result.sendParcelUpdateToAvatarsOverMe(); |
298 | 298 | ||
299 | 299 | ||
300 | 300 | ||
301 | 301 | ||
302 | return true; | 302 | return true; |
303 | } | 303 | } |
304 | /// <summary> | 304 | /// <summary> |
305 | /// Join 2 parcels together | 305 | /// Join 2 parcels together |
306 | /// </summary> | 306 | /// </summary> |
307 | /// <param name="start_x">x value in first parcel</param> | 307 | /// <param name="start_x">x value in first parcel</param> |
308 | /// <param name="start_y">y value in first parcel</param> | 308 | /// <param name="start_y">y value in first parcel</param> |
309 | /// <param name="end_x">x value in second parcel</param> | 309 | /// <param name="end_x">x value in second parcel</param> |
310 | /// <param name="end_y">y value in second parcel</param> | 310 | /// <param name="end_y">y value in second parcel</param> |
311 | /// <param name="attempting_user_id">LLUUID of the avatar trying to join the parcels</param> | 311 | /// <param name="attempting_user_id">LLUUID of the avatar trying to join the parcels</param> |
312 | /// <returns>Returns true if successful</returns> | 312 | /// <returns>Returns true if successful</returns> |
313 | private bool join(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id) | 313 | private bool join(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id) |
314 | { | 314 | { |
315 | end_x -= 4; | 315 | end_x -= 4; |
316 | end_y -= 4; | 316 | end_y -= 4; |
317 | 317 | ||
318 | List<Parcel> selectedParcels = new List<Parcel>(); | 318 | List<Parcel> selectedParcels = new List<Parcel>(); |
319 | int stepXSelected = 0; | 319 | int stepXSelected = 0; |
320 | int stepYSelected = 0; | 320 | int stepYSelected = 0; |
321 | for (stepYSelected = start_y; stepYSelected <= end_y; stepYSelected += 4) | 321 | for (stepYSelected = start_y; stepYSelected <= end_y; stepYSelected += 4) |
322 | { | 322 | { |
323 | for (stepXSelected = start_x; stepXSelected <= end_x; stepXSelected += 4) | 323 | for (stepXSelected = start_x; stepXSelected <= end_x; stepXSelected += 4) |
324 | { | 324 | { |
325 | Parcel p = getParcel(stepXSelected,stepYSelected); | 325 | Parcel p = getParcel(stepXSelected,stepYSelected); |
326 | if (!selectedParcels.Contains(p)) | 326 | if (!selectedParcels.Contains(p)) |
327 | { | 327 | { |
328 | selectedParcels.Add(p); | 328 | selectedParcels.Add(p); |
329 | } | 329 | } |
330 | } | 330 | } |
331 | } | 331 | } |
332 | Parcel masterParcel = selectedParcels[0]; | 332 | Parcel masterParcel = selectedParcels[0]; |
333 | selectedParcels.RemoveAt(0); | 333 | selectedParcels.RemoveAt(0); |
334 | 334 | ||
335 | 335 | ||
336 | if (selectedParcels.Count < 1) | 336 | if (selectedParcels.Count < 1) |
337 | { | 337 | { |
338 | return false; //Only one parcel selected | 338 | return false; //Only one parcel selected |
339 | } | 339 | } |
340 | if (masterParcel.parcelData.ownerID != attempting_user_id) | 340 | if (masterParcel.parcelData.ownerID != attempting_user_id) |
341 | { | 341 | { |
342 | return false; //Not the same owner | 342 | return false; //Not the same owner |
343 | } | 343 | } |
344 | foreach (Parcel p in selectedParcels) | 344 | foreach (Parcel p in selectedParcels) |
345 | { | 345 | { |
346 | if (p.parcelData.ownerID != masterParcel.parcelData.ownerID) | 346 | if (p.parcelData.ownerID != masterParcel.parcelData.ownerID) |
347 | { | 347 | { |
348 | return false; //Over multiple users. TODO: make this just ignore this parcel? | 348 | return false; //Over multiple users. TODO: make this just ignore this parcel? |
349 | } | 349 | } |
350 | } | 350 | } |
351 | foreach (Parcel slaveParcel in selectedParcels) | 351 | foreach (Parcel slaveParcel in selectedParcels) |
352 | { | 352 | { |
353 | parcelList[masterParcel.parcelData.localID].setParcelBitmap(Parcel.mergeParcelBitmaps(masterParcel.getParcelBitmap(), slaveParcel.getParcelBitmap())); | 353 | parcelList[masterParcel.parcelData.localID].setParcelBitmap(Parcel.mergeParcelBitmaps(masterParcel.getParcelBitmap(), slaveParcel.getParcelBitmap())); |
354 | performFinalParcelJoin(masterParcel, slaveParcel); | 354 | performFinalParcelJoin(masterParcel, slaveParcel); |
355 | } | 355 | } |
356 | 356 | ||
357 | 357 | ||
358 | this.setPrimsTainted(); | 358 | this.setPrimsTainted(); |
359 | 359 | ||
360 | masterParcel.sendParcelUpdateToAvatarsOverMe(); | 360 | masterParcel.sendParcelUpdateToAvatarsOverMe(); |
361 | 361 | ||
362 | return true; | 362 | return true; |
363 | 363 | ||
364 | 364 | ||
365 | 365 | ||
366 | } | 366 | } |
367 | #endregion | 367 | #endregion |
368 | 368 | ||
369 | #region Parcel Updating | 369 | #region Parcel Updating |
370 | /// <summary> | 370 | /// <summary> |
371 | /// Where we send the ParcelOverlay packet to the client | 371 | /// Where we send the ParcelOverlay packet to the client |
372 | /// </summary> | 372 | /// </summary> |
373 | /// <param name="remote_client">The object representing the client</param> | 373 | /// <param name="remote_client">The object representing the client</param> |
374 | public void sendParcelOverlay(IClientAPI remote_client) | 374 | public void sendParcelOverlay(IClientAPI remote_client) |
375 | { | 375 | { |
376 | const int PARCEL_BLOCKS_PER_PACKET = 1024; | 376 | const int PARCEL_BLOCKS_PER_PACKET = 1024; |
377 | int x, y = 0; | 377 | int x, y = 0; |
378 | byte[] byteArray = new byte[PARCEL_BLOCKS_PER_PACKET]; | 378 | byte[] byteArray = new byte[PARCEL_BLOCKS_PER_PACKET]; |
379 | int byteArrayCount = 0; | 379 | int byteArrayCount = 0; |
380 | int sequenceID = 0; | 380 | int sequenceID = 0; |
381 | ParcelOverlayPacket packet; | 381 | ParcelOverlayPacket packet; |
382 | 382 | ||
383 | for (y = 0; y < 64; y++) | 383 | for (y = 0; y < 64; y++) |
384 | { | 384 | { |
385 | for (x = 0; x < 64; x++) | 385 | for (x = 0; x < 64; x++) |
386 | { | 386 | { |
387 | byte tempByte = (byte)0; //This represents the byte for the current 4x4 | 387 | byte tempByte = (byte)0; //This represents the byte for the current 4x4 |
388 | Parcel currentParcelBlock = getParcel(x * 4, y * 4); | 388 | Parcel currentParcelBlock = getParcel(x * 4, y * 4); |
389 | 389 | ||
390 | if (currentParcelBlock.parcelData.ownerID == remote_client.AgentId) | 390 | if (currentParcelBlock.parcelData.ownerID == remote_client.AgentId) |
391 | { | 391 | { |
392 | //Owner Flag | 392 | //Owner Flag |
393 | tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_OWNED_BY_REQUESTER); | 393 | tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_OWNED_BY_REQUESTER); |
394 | } | 394 | } |
395 | else if (currentParcelBlock.parcelData.salePrice > 0 && (currentParcelBlock.parcelData.authBuyerID == LLUUID.Zero || currentParcelBlock.parcelData.authBuyerID == remote_client.AgentId)) | 395 | else if (currentParcelBlock.parcelData.salePrice > 0 && (currentParcelBlock.parcelData.authBuyerID == LLUUID.Zero || currentParcelBlock.parcelData.authBuyerID == remote_client.AgentId)) |
396 | { | 396 | { |
397 | //Sale Flag | 397 | //Sale Flag |
398 | tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_IS_FOR_SALE); | 398 | tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_IS_FOR_SALE); |
399 | } | 399 | } |
400 | else if (currentParcelBlock.parcelData.ownerID == LLUUID.Zero) | 400 | else if (currentParcelBlock.parcelData.ownerID == LLUUID.Zero) |
401 | { | 401 | { |
402 | //Public Flag | 402 | //Public Flag |
403 | tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_PUBLIC); | 403 | tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_PUBLIC); |
404 | } | 404 | } |
405 | else | 405 | else |
406 | { | 406 | { |
407 | //Other Flag | 407 | //Other Flag |
408 | tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_OWNED_BY_OTHER); | 408 | tempByte = Convert.ToByte(tempByte | PARCEL_TYPE_OWNED_BY_OTHER); |
409 | } | 409 | } |
410 | 410 | ||
411 | 411 | ||
412 | //Now for border control | 412 | //Now for border control |
413 | if (x == 0) | 413 | if (x == 0) |
414 | { | 414 | { |
415 | tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_WEST); | 415 | tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_WEST); |
416 | } | 416 | } |
417 | else if (getParcel((x - 1) * 4, y * 4) != currentParcelBlock) | 417 | else if (getParcel((x - 1) * 4, y * 4) != currentParcelBlock) |
418 | { | 418 | { |
419 | tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_WEST); | 419 | tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_WEST); |
420 | } | 420 | } |
421 | 421 | ||
422 | if (y == 0) | 422 | if (y == 0) |
423 | { | 423 | { |
424 | tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_SOUTH); | 424 | tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_SOUTH); |
425 | } | 425 | } |
426 | else if (getParcel(x * 4, (y - 1) * 4) != currentParcelBlock) | 426 | else if (getParcel(x * 4, (y - 1) * 4) != currentParcelBlock) |
427 | { | 427 | { |
428 | tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_SOUTH); | 428 | tempByte = Convert.ToByte(tempByte | PARCEL_FLAG_PROPERTY_BORDER_SOUTH); |
429 | } | 429 | } |
430 | 430 | ||
431 | byteArray[byteArrayCount] = tempByte; | 431 | byteArray[byteArrayCount] = tempByte; |
432 | byteArrayCount++; | 432 | byteArrayCount++; |
433 | if (byteArrayCount >= PARCEL_BLOCKS_PER_PACKET) | 433 | if (byteArrayCount >= PARCEL_BLOCKS_PER_PACKET) |
434 | { | 434 | { |
435 | byteArrayCount = 0; | 435 | byteArrayCount = 0; |
436 | packet = new ParcelOverlayPacket(); | 436 | packet = new ParcelOverlayPacket(); |
437 | packet.ParcelData.Data = byteArray; | 437 | packet.ParcelData.Data = byteArray; |
438 | packet.ParcelData.SequenceID = sequenceID; | 438 | packet.ParcelData.SequenceID = sequenceID; |
439 | remote_client.OutPacket((Packet)packet); | 439 | remote_client.OutPacket((Packet)packet); |
440 | sequenceID++; | 440 | sequenceID++; |
441 | byteArray = new byte[PARCEL_BLOCKS_PER_PACKET]; | 441 | byteArray = new byte[PARCEL_BLOCKS_PER_PACKET]; |
442 | } | 442 | } |
443 | } | 443 | } |
444 | } | 444 | } |
445 | 445 | ||
446 | 446 | ||
447 | } | 447 | } |
448 | 448 | ||
449 | public void handleParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id, bool snap_selection, IClientAPI remote_client) | 449 | public void handleParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id, bool snap_selection, IClientAPI remote_client) |
450 | { | 450 | { |
451 | //Get the parcels within the bounds | 451 | //Get the parcels within the bounds |
452 | List<Parcel> temp = new List<Parcel>(); | 452 | List<Parcel> temp = new List<Parcel>(); |
453 | int x, y, i; | 453 | int x, y, i; |
454 | int inc_x = end_x - start_x; | 454 | int inc_x = end_x - start_x; |
455 | int inc_y = end_y - start_y; | 455 | int inc_y = end_y - start_y; |
456 | for (x = 0; x < inc_x; x++) | 456 | for (x = 0; x < inc_x; x++) |
457 | { | 457 | { |
458 | for (y = 0; y < inc_y; y++) | 458 | for (y = 0; y < inc_y; y++) |
459 | { | 459 | { |
460 | Parcel currentParcel = getParcel(start_x + x, start_y + y); | 460 | Parcel currentParcel = getParcel(start_x + x, start_y + y); |
461 | if (!temp.Contains(currentParcel)) | 461 | if (!temp.Contains(currentParcel)) |
462 | { | 462 | { |
463 | currentParcel.forceUpdateParcelInfo(); | 463 | currentParcel.forceUpdateParcelInfo(); |
464 | temp.Add(currentParcel); | 464 | temp.Add(currentParcel); |
465 | } | 465 | } |
466 | } | 466 | } |
467 | } | 467 | } |
468 | 468 | ||
469 | int requestResult = PARCEL_RESULT_ONE_PARCEL; | 469 | int requestResult = PARCEL_RESULT_ONE_PARCEL; |
470 | if (temp.Count > 1) | 470 | if (temp.Count > 1) |
471 | { | 471 | { |
472 | requestResult = PARCEL_RESULT_MULTIPLE_PARCELS; | 472 | requestResult = PARCEL_RESULT_MULTIPLE_PARCELS; |
473 | } | 473 | } |
474 | 474 | ||
475 | for (i = 0; i < temp.Count; i++) | 475 | for (i = 0; i < temp.Count; i++) |
476 | { | 476 | { |
477 | temp[i].sendParcelProperties(sequence_id, snap_selection, requestResult, remote_client); | 477 | temp[i].sendParcelProperties(sequence_id, snap_selection, requestResult, remote_client); |
478 | } | 478 | } |
479 | 479 | ||
480 | 480 | ||
481 | sendParcelOverlay(remote_client); | 481 | sendParcelOverlay(remote_client); |
482 | } | 482 | } |
483 | 483 | ||
484 | public void handleParcelPropertiesUpdateRequest(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client) | 484 | public void handleParcelPropertiesUpdateRequest(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client) |
485 | { | 485 | { |
486 | if (parcelList.ContainsKey(packet.ParcelData.LocalID)) | 486 | if (parcelList.ContainsKey(packet.ParcelData.LocalID)) |
487 | { | 487 | { |
488 | parcelList[packet.ParcelData.LocalID].updateParcelProperties(packet, remote_client); | 488 | parcelList[packet.ParcelData.LocalID].updateParcelProperties(packet, remote_client); |
489 | } | 489 | } |
490 | } | 490 | } |
491 | public void handleParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client) | 491 | public void handleParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client) |
492 | { | 492 | { |
493 | subdivide(west, south, east, north, remote_client.AgentId); | 493 | subdivide(west, south, east, north, remote_client.AgentId); |
494 | } | 494 | } |
495 | public void handleParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client) | 495 | public void handleParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client) |
496 | { | 496 | { |
497 | join(west, south, east, north, remote_client.AgentId); | 497 | join(west, south, east, north, remote_client.AgentId); |
498 | 498 | ||
499 | } | 499 | } |
500 | 500 | ||
501 | public void handleParcelSelectObjectsRequest(int local_id, int request_type, IClientAPI remote_client) | 501 | public void handleParcelSelectObjectsRequest(int local_id, int request_type, IClientAPI remote_client) |
502 | { | 502 | { |
503 | parcelList[local_id].sendForceObjectSelect(local_id, request_type, remote_client); | 503 | parcelList[local_id].sendForceObjectSelect(local_id, request_type, remote_client); |
504 | } | 504 | } |
505 | 505 | ||
506 | public void handleParcelObjectOwnersRequest(int local_id, IClientAPI remote_client) | 506 | public void handleParcelObjectOwnersRequest(int local_id, IClientAPI remote_client) |
507 | { | 507 | { |
508 | parcelList[local_id].sendParcelObjectOwners(remote_client); | 508 | parcelList[local_id].sendParcelObjectOwners(remote_client); |
509 | } | 509 | } |
510 | #endregion | 510 | #endregion |
511 | 511 | ||
512 | /// <summary> | 512 | /// <summary> |
513 | /// Resets the sim to the default parcel (full sim parcel owned by the default user) | 513 | /// Resets the sim to the default parcel (full sim parcel owned by the default user) |
514 | /// </summary> | 514 | /// </summary> |
515 | public void resetSimParcels() | 515 | public void resetSimParcels() |
516 | { | 516 | { |
517 | //Remove all the parcels in the sim and add a blank, full sim parcel set to public | 517 | //Remove all the parcels in the sim and add a blank, full sim parcel set to public |
518 | parcelList.Clear(); | 518 | parcelList.Clear(); |
519 | lastParcelLocalID = START_PARCEL_LOCAL_ID - 1; | 519 | lastParcelLocalID = START_PARCEL_LOCAL_ID - 1; |
520 | parcelIDList.Initialize(); | 520 | parcelIDList.Initialize(); |
521 | 521 | ||
522 | Parcel fullSimParcel = new Parcel(LLUUID.Zero, false, m_world); | 522 | Parcel fullSimParcel = new Parcel(LLUUID.Zero, false, m_world); |
523 | 523 | ||
524 | fullSimParcel.setParcelBitmap(Parcel.getSquareParcelBitmap(0, 0, 256, 256)); | 524 | fullSimParcel.setParcelBitmap(Parcel.getSquareParcelBitmap(0, 0, 256, 256)); |
525 | fullSimParcel.parcelData.ownerID = m_regInfo.MasterAvatarAssignedUUID; | 525 | fullSimParcel.parcelData.ownerID = m_regInfo.MasterAvatarAssignedUUID; |
526 | 526 | ||
527 | addParcel(fullSimParcel); | 527 | addParcel(fullSimParcel); |
528 | 528 | ||
529 | } | 529 | } |
530 | 530 | ||
531 | 531 | ||
532 | public void handleSignificantClientMovement(IClientAPI remote_client) | 532 | public void handleSignificantClientMovement(IClientAPI remote_client) |
533 | { | 533 | { |
534 | Avatar clientAvatar = m_world.RequestAvatar(remote_client.AgentId); | 534 | Avatar clientAvatar = m_world.RequestAvatar(remote_client.AgentId); |
535 | if (clientAvatar != null) | 535 | if (clientAvatar != null) |
536 | { | 536 | { |
537 | Parcel over = getParcel(clientAvatar.Pos.X,clientAvatar.Pos.Y); | 537 | Parcel over = getParcel(clientAvatar.Pos.X,clientAvatar.Pos.Y); |
538 | if (over != null) | 538 | if (over != null) |
539 | { | 539 | { |
540 | over.sendParcelProperties(0, false, 0, remote_client); | 540 | over.sendParcelProperties(0, false, 0, remote_client); |
541 | } | 541 | } |
542 | } | 542 | } |
543 | } | 543 | } |
544 | 544 | ||
545 | public void resetAllParcelPrimCounts() | 545 | public void resetAllParcelPrimCounts() |
546 | { | 546 | { |
547 | foreach (Parcel p in parcelList.Values) | 547 | foreach (Parcel p in parcelList.Values) |
548 | { | 548 | { |
549 | p.resetParcelPrimCounts(); | 549 | p.resetParcelPrimCounts(); |
550 | } | 550 | } |
551 | } | 551 | } |
552 | public void setPrimsTainted() | 552 | public void setPrimsTainted() |
553 | { | 553 | { |
554 | this.parcelPrimCountTainted = true; | 554 | this.parcelPrimCountTainted = true; |
555 | } | 555 | } |
556 | 556 | ||
557 | public void addPrimToParcelCounts(SceneObject obj) | 557 | public void addPrimToParcelCounts(SceneObject obj) |
558 | { | 558 | { |
559 | LLVector3 position = obj.Pos; | 559 | LLVector3 position = obj.Pos; |
560 | Parcel parcelUnderPrim = getParcel(position.X, position.Y); | 560 | Parcel parcelUnderPrim = getParcel(position.X, position.Y); |
561 | if (parcelUnderPrim != null) | 561 | if (parcelUnderPrim != null) |
562 | { | 562 | { |
563 | parcelUnderPrim.addPrimToCount(obj); | 563 | parcelUnderPrim.addPrimToCount(obj); |
564 | } | 564 | } |
565 | } | 565 | } |
566 | 566 | ||
567 | public void removePrimFromParcelCounts(SceneObject obj) | 567 | public void removePrimFromParcelCounts(SceneObject obj) |
568 | { | 568 | { |
569 | foreach (Parcel p in parcelList.Values) | 569 | foreach (Parcel p in parcelList.Values) |
570 | { | 570 | { |
571 | p.removePrimFromCount(obj); | 571 | p.removePrimFromCount(obj); |
572 | } | 572 | } |
573 | } | 573 | } |
574 | 574 | ||
575 | public void finalizeParcelPrimCountUpdate() | 575 | public void finalizeParcelPrimCountUpdate() |
576 | { | 576 | { |
577 | //Get Simwide prim count for owner | 577 | //Get Simwide prim count for owner |
578 | Dictionary<LLUUID, List<Parcel>> parcelOwnersAndParcels = new Dictionary<LLUUID,List<Parcel>>(); | 578 | Dictionary<LLUUID, List<Parcel>> parcelOwnersAndParcels = new Dictionary<LLUUID,List<Parcel>>(); |
579 | foreach (Parcel p in parcelList.Values) | 579 | foreach (Parcel p in parcelList.Values) |
580 | { | 580 | { |
581 | if(!parcelOwnersAndParcels.ContainsKey(p.parcelData.ownerID)) | 581 | if(!parcelOwnersAndParcels.ContainsKey(p.parcelData.ownerID)) |
582 | { | 582 | { |
583 | List<Parcel> tempList = new List<Parcel>(); | 583 | List<Parcel> tempList = new List<Parcel>(); |
584 | tempList.Add(p); | 584 | tempList.Add(p); |
585 | parcelOwnersAndParcels.Add(p.parcelData.ownerID,tempList); | 585 | parcelOwnersAndParcels.Add(p.parcelData.ownerID,tempList); |
586 | } | 586 | } |
587 | else | 587 | else |
588 | { | 588 | { |
589 | parcelOwnersAndParcels[p.parcelData.ownerID].Add(p); | 589 | parcelOwnersAndParcels[p.parcelData.ownerID].Add(p); |
590 | } | 590 | } |
591 | } | 591 | } |
592 | 592 | ||
593 | foreach (LLUUID owner in parcelOwnersAndParcels.Keys) | 593 | foreach (LLUUID owner in parcelOwnersAndParcels.Keys) |
594 | { | 594 | { |
595 | int simArea = 0; | 595 | int simArea = 0; |
596 | int simPrims = 0; | 596 | int simPrims = 0; |
597 | foreach (Parcel p in parcelOwnersAndParcels[owner]) | 597 | foreach (Parcel p in parcelOwnersAndParcels[owner]) |
598 | { | 598 | { |
599 | simArea += p.parcelData.area; | 599 | simArea += p.parcelData.area; |
600 | simPrims += p.parcelData.ownerPrims + p.parcelData.otherPrims + p.parcelData.groupPrims + p.parcelData.selectedPrims; | 600 | simPrims += p.parcelData.ownerPrims + p.parcelData.otherPrims + p.parcelData.groupPrims + p.parcelData.selectedPrims; |
601 | } | 601 | } |
602 | 602 | ||
603 | foreach (Parcel p in parcelOwnersAndParcels[owner]) | 603 | foreach (Parcel p in parcelOwnersAndParcels[owner]) |
604 | { | 604 | { |
605 | p.parcelData.simwideArea = simArea; | 605 | p.parcelData.simwideArea = simArea; |
606 | p.parcelData.simwidePrims = simPrims; | 606 | p.parcelData.simwidePrims = simPrims; |
607 | } | 607 | } |
608 | } | 608 | } |
609 | 609 | ||
610 | } | 610 | } |
611 | #endregion | 611 | #endregion |
612 | } | 612 | } |
613 | #endregion | 613 | #endregion |
614 | 614 | ||
615 | 615 | ||
616 | #region Parcel Class | 616 | #region Parcel Class |
617 | /// <summary> | 617 | /// <summary> |
618 | /// Keeps track of a specific parcel's information | 618 | /// Keeps track of a specific parcel's information |
619 | /// </summary> | 619 | /// </summary> |
620 | public class Parcel | 620 | public class Parcel |
621 | { | 621 | { |
622 | #region Member Variables | 622 | #region Member Variables |
623 | public ParcelData parcelData = new ParcelData(); | 623 | public ParcelData parcelData = new ParcelData(); |
624 | public List<SceneObject> primsOverMe = new List<SceneObject>(); | 624 | public List<SceneObject> primsOverMe = new List<SceneObject>(); |
625 | 625 | ||
626 | public Scene m_world; | 626 | public Scene m_world; |
627 | 627 | ||
628 | private bool[,] parcelBitmap = new bool[64, 64]; | 628 | private bool[,] parcelBitmap = new bool[64, 64]; |
629 | 629 | ||
630 | #endregion | 630 | #endregion |
631 | 631 | ||
632 | 632 | ||
633 | #region Constructors | 633 | #region Constructors |
634 | public Parcel(LLUUID owner_id, bool is_group_owned, Scene world) | 634 | public Parcel(LLUUID owner_id, bool is_group_owned, Scene world) |
635 | { | 635 | { |
636 | m_world = world; | 636 | m_world = world; |
637 | parcelData.ownerID = owner_id; | 637 | parcelData.ownerID = owner_id; |
638 | parcelData.isGroupOwned = is_group_owned; | 638 | parcelData.isGroupOwned = is_group_owned; |
639 | 639 | ||
640 | } | 640 | } |
641 | #endregion | 641 | #endregion |
642 | 642 | ||
643 | 643 | ||
644 | #region Member Functions | 644 | #region Member Functions |
645 | 645 | ||
646 | #region General Functions | 646 | #region General Functions |
647 | /// <summary> | 647 | /// <summary> |
648 | /// Checks to see if this parcel contains a point | 648 | /// Checks to see if this parcel contains a point |
649 | /// </summary> | 649 | /// </summary> |
650 | /// <param name="x"></param> | 650 | /// <param name="x"></param> |
651 | /// <param name="y"></param> | 651 | /// <param name="y"></param> |
652 | /// <returns>Returns true if the parcel contains the specified point</returns> | 652 | /// <returns>Returns true if the parcel contains the specified point</returns> |
653 | public bool containsPoint(int x, int y) | 653 | public bool containsPoint(int x, int y) |
654 | { | 654 | { |
655 | if (x >= 0 && y >= 0 && x <= 256 && x <= 256) | 655 | if (x >= 0 && y >= 0 && x <= 256 && x <= 256) |
656 | { | 656 | { |
657 | return (parcelBitmap[x / 4, y / 4] == true); | 657 | return (parcelBitmap[x / 4, y / 4] == true); |
658 | } | 658 | } |
659 | else | 659 | else |
660 | { | 660 | { |
661 | return false; | 661 | return false; |
662 | } | 662 | } |
663 | } | 663 | } |
664 | 664 | ||
665 | public Parcel Copy() | 665 | public Parcel Copy() |
666 | { | 666 | { |
667 | Parcel newParcel = new Parcel(this.parcelData.ownerID, this.parcelData.isGroupOwned, m_world); | 667 | Parcel newParcel = new Parcel(this.parcelData.ownerID, this.parcelData.isGroupOwned, m_world); |
668 | 668 | ||
669 | //Place all new variables here! | 669 | //Place all new variables here! |
670 | newParcel.parcelBitmap = (bool[,])(this.parcelBitmap.Clone()); | 670 | newParcel.parcelBitmap = (bool[,])(this.parcelBitmap.Clone()); |
671 | newParcel.parcelData = parcelData.Copy(); | 671 | newParcel.parcelData = parcelData.Copy(); |
672 | 672 | ||
673 | return newParcel; | 673 | return newParcel; |
674 | } | 674 | } |
675 | 675 | ||
676 | #endregion | 676 | #endregion |
677 | 677 | ||
678 | 678 | ||
679 | #region Packet Request Handling | 679 | #region Packet Request Handling |
680 | /// <summary> | 680 | /// <summary> |
681 | /// Sends parcel properties as requested | 681 | /// Sends parcel properties as requested |
682 | /// </summary> | 682 | /// </summary> |
683 | /// <param name="sequence_id">ID sent by client for them to keep track of</param> | 683 | /// <param name="sequence_id">ID sent by client for them to keep track of</param> |
684 | /// <param name="snap_selection">Bool sent by client for them to use</param> | 684 | /// <param name="snap_selection">Bool sent by client for them to use</param> |
685 | /// <param name="remote_client">Object representing the client</param> | 685 | /// <param name="remote_client">Object representing the client</param> |
686 | public void sendParcelProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client) | 686 | public void sendParcelProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client) |
687 | { | 687 | { |
688 | 688 | ||
689 | ParcelPropertiesPacket updatePacket = new ParcelPropertiesPacket(); | 689 | ParcelPropertiesPacket updatePacket = new ParcelPropertiesPacket(); |
690 | updatePacket.ParcelData.AABBMax = parcelData.AABBMax; | 690 | updatePacket.ParcelData.AABBMax = parcelData.AABBMax; |
691 | updatePacket.ParcelData.AABBMin = parcelData.AABBMin; | 691 | updatePacket.ParcelData.AABBMin = parcelData.AABBMin; |
692 | updatePacket.ParcelData.Area = parcelData.area; | 692 | updatePacket.ParcelData.Area = parcelData.area; |
693 | updatePacket.ParcelData.AuctionID = parcelData.auctionID; | 693 | updatePacket.ParcelData.AuctionID = parcelData.auctionID; |
694 | updatePacket.ParcelData.AuthBuyerID = parcelData.authBuyerID; //unemplemented | 694 | updatePacket.ParcelData.AuthBuyerID = parcelData.authBuyerID; //unemplemented |
695 | 695 | ||
696 | updatePacket.ParcelData.Bitmap = parcelData.parcelBitmapByteArray; | 696 | updatePacket.ParcelData.Bitmap = parcelData.parcelBitmapByteArray; |
697 | 697 | ||
698 | updatePacket.ParcelData.Desc = Helpers.StringToField(parcelData.parcelDesc); | 698 | updatePacket.ParcelData.Desc = Helpers.StringToField(parcelData.parcelDesc); |
699 | updatePacket.ParcelData.Category = (byte)parcelData.category; | 699 | updatePacket.ParcelData.Category = (byte)parcelData.category; |
700 | updatePacket.ParcelData.ClaimDate = parcelData.claimDate; | 700 | updatePacket.ParcelData.ClaimDate = parcelData.claimDate; |
701 | updatePacket.ParcelData.ClaimPrice = parcelData.claimPrice; | 701 | updatePacket.ParcelData.ClaimPrice = parcelData.claimPrice; |
702 | updatePacket.ParcelData.GroupID = parcelData.groupID; | 702 | updatePacket.ParcelData.GroupID = parcelData.groupID; |
703 | updatePacket.ParcelData.GroupPrims = parcelData.groupPrims; | 703 | updatePacket.ParcelData.GroupPrims = parcelData.groupPrims; |
704 | updatePacket.ParcelData.IsGroupOwned = parcelData.isGroupOwned; | 704 | updatePacket.ParcelData.IsGroupOwned = parcelData.isGroupOwned; |
705 | updatePacket.ParcelData.LandingType = (byte)parcelData.landingType; | 705 | updatePacket.ParcelData.LandingType = (byte)parcelData.landingType; |
706 | updatePacket.ParcelData.LocalID = parcelData.localID; | 706 | updatePacket.ParcelData.LocalID = parcelData.localID; |
707 | if (parcelData.area > 0) | 707 | if (parcelData.area > 0) |
708 | { | 708 | { |
709 | updatePacket.ParcelData.MaxPrims = Convert.ToInt32(Math.Round((Convert.ToDecimal(parcelData.area) / Convert.ToDecimal(65536)) * 15000 * Convert.ToDecimal(m_world.RegionInfo.estateSettings.objectBonusFactor))); | 709 | updatePacket.ParcelData.MaxPrims = Convert.ToInt32(Math.Round((Convert.ToDecimal(parcelData.area) / Convert.ToDecimal(65536)) * 15000 * Convert.ToDecimal(m_world.RegionInfo.estateSettings.objectBonusFactor))); |
710 | } | 710 | } |
711 | else | 711 | else |
712 | { | 712 | { |
713 | updatePacket.ParcelData.MaxPrims = 0; | 713 | updatePacket.ParcelData.MaxPrims = 0; |
714 | } | 714 | } |
715 | updatePacket.ParcelData.MediaAutoScale = parcelData.mediaAutoScale; | 715 | updatePacket.ParcelData.MediaAutoScale = parcelData.mediaAutoScale; |
716 | updatePacket.ParcelData.MediaID = parcelData.mediaID; | 716 | updatePacket.ParcelData.MediaID = parcelData.mediaID; |
717 | updatePacket.ParcelData.MediaURL = Helpers.StringToField(parcelData.mediaURL); | 717 | updatePacket.ParcelData.MediaURL = Helpers.StringToField(parcelData.mediaURL); |
718 | updatePacket.ParcelData.MusicURL = Helpers.StringToField(parcelData.musicURL); | 718 | updatePacket.ParcelData.MusicURL = Helpers.StringToField(parcelData.musicURL); |
719 | updatePacket.ParcelData.Name = Helpers.StringToField(parcelData.parcelName); | 719 | updatePacket.ParcelData.Name = Helpers.StringToField(parcelData.parcelName); |
720 | updatePacket.ParcelData.OtherCleanTime = 0; //unemplemented | 720 | updatePacket.ParcelData.OtherCleanTime = 0; //unemplemented |
721 | updatePacket.ParcelData.OtherCount = 0; //unemplemented | 721 | updatePacket.ParcelData.OtherCount = 0; //unemplemented |
722 | updatePacket.ParcelData.OtherPrims = parcelData.otherPrims; | 722 | updatePacket.ParcelData.OtherPrims = parcelData.otherPrims; |
723 | updatePacket.ParcelData.OwnerID = parcelData.ownerID; | 723 | updatePacket.ParcelData.OwnerID = parcelData.ownerID; |
724 | updatePacket.ParcelData.OwnerPrims = parcelData.ownerPrims; | 724 | updatePacket.ParcelData.OwnerPrims = parcelData.ownerPrims; |
725 | updatePacket.ParcelData.ParcelFlags = parcelData.parcelFlags; | 725 | updatePacket.ParcelData.ParcelFlags = parcelData.parcelFlags; |
726 | updatePacket.ParcelData.ParcelPrimBonus = m_world.RegionInfo.estateSettings.objectBonusFactor; | 726 | updatePacket.ParcelData.ParcelPrimBonus = m_world.RegionInfo.estateSettings.objectBonusFactor; |
727 | updatePacket.ParcelData.PassHours = parcelData.passHours; | 727 | updatePacket.ParcelData.PassHours = parcelData.passHours; |
728 | updatePacket.ParcelData.PassPrice = parcelData.passPrice; | 728 | updatePacket.ParcelData.PassPrice = parcelData.passPrice; |
729 | updatePacket.ParcelData.PublicCount = 0; //unemplemented | 729 | updatePacket.ParcelData.PublicCount = 0; //unemplemented |
730 | updatePacket.ParcelData.RegionDenyAnonymous = (((uint)m_world.RegionInfo.estateSettings.regionFlags & (uint)Simulator.RegionFlags.DenyAnonymous) > 0); | 730 | updatePacket.ParcelData.RegionDenyAnonymous = (((uint)m_world.RegionInfo.estateSettings.regionFlags & (uint)Simulator.RegionFlags.DenyAnonymous) > 0); |
731 | updatePacket.ParcelData.RegionDenyIdentified = (((uint)m_world.RegionInfo.estateSettings.regionFlags & (uint)Simulator.RegionFlags.DenyIdentified) > 0); | 731 | updatePacket.ParcelData.RegionDenyIdentified = (((uint)m_world.RegionInfo.estateSettings.regionFlags & (uint)Simulator.RegionFlags.DenyIdentified) > 0); |
732 | updatePacket.ParcelData.RegionDenyTransacted = (((uint)m_world.RegionInfo.estateSettings.regionFlags & (uint)Simulator.RegionFlags.DenyTransacted) > 0); | 732 | updatePacket.ParcelData.RegionDenyTransacted = (((uint)m_world.RegionInfo.estateSettings.regionFlags & (uint)Simulator.RegionFlags.DenyTransacted) > 0); |
733 | updatePacket.ParcelData.RegionPushOverride = (((uint)m_world.RegionInfo.estateSettings.regionFlags & (uint)Simulator.RegionFlags.RestrictPushObject) > 0); | 733 | updatePacket.ParcelData.RegionPushOverride = (((uint)m_world.RegionInfo.estateSettings.regionFlags & (uint)Simulator.RegionFlags.RestrictPushObject) > 0); |
734 | updatePacket.ParcelData.RentPrice = 0; | 734 | updatePacket.ParcelData.RentPrice = 0; |
735 | updatePacket.ParcelData.RequestResult = request_result; | 735 | updatePacket.ParcelData.RequestResult = request_result; |
736 | updatePacket.ParcelData.SalePrice = parcelData.salePrice; | 736 | updatePacket.ParcelData.SalePrice = parcelData.salePrice; |
737 | updatePacket.ParcelData.SelectedPrims = parcelData.selectedPrims; | 737 | updatePacket.ParcelData.SelectedPrims = parcelData.selectedPrims; |
738 | updatePacket.ParcelData.SelfCount = 0;//unemplemented | 738 | updatePacket.ParcelData.SelfCount = 0;//unemplemented |
739 | updatePacket.ParcelData.SequenceID = sequence_id; | 739 | updatePacket.ParcelData.SequenceID = sequence_id; |
740 | if (parcelData.simwideArea > 0) | 740 | if (parcelData.simwideArea > 0) |
741 | { | 741 | { |
742 | updatePacket.ParcelData.SimWideMaxPrims = Convert.ToInt32(Math.Round((Convert.ToDecimal(parcelData.simwideArea) / Convert.ToDecimal(65536)) * 15000 * Convert.ToDecimal(m_world.RegionInfo.estateSettings.objectBonusFactor))); | 742 | updatePacket.ParcelData.SimWideMaxPrims = Convert.ToInt32(Math.Round((Convert.ToDecimal(parcelData.simwideArea) / Convert.ToDecimal(65536)) * 15000 * Convert.ToDecimal(m_world.RegionInfo.estateSettings.objectBonusFactor))); |
743 | } | 743 | } |
744 | else | 744 | else |
745 | { | 745 | { |
746 | updatePacket.ParcelData.SimWideMaxPrims = 0; | 746 | updatePacket.ParcelData.SimWideMaxPrims = 0; |
747 | } | 747 | } |
748 | updatePacket.ParcelData.SimWideTotalPrims = parcelData.simwidePrims; | 748 | updatePacket.ParcelData.SimWideTotalPrims = parcelData.simwidePrims; |
749 | updatePacket.ParcelData.SnapSelection = snap_selection; | 749 | updatePacket.ParcelData.SnapSelection = snap_selection; |
750 | updatePacket.ParcelData.SnapshotID = parcelData.snapshotID; | 750 | updatePacket.ParcelData.SnapshotID = parcelData.snapshotID; |
751 | updatePacket.ParcelData.Status = (byte)parcelData.parcelStatus; | 751 | updatePacket.ParcelData.Status = (byte)parcelData.parcelStatus; |
752 | updatePacket.ParcelData.TotalPrims = parcelData.ownerPrims + parcelData.groupPrims + parcelData.otherPrims + parcelData.selectedPrims; | 752 | updatePacket.ParcelData.TotalPrims = parcelData.ownerPrims + parcelData.groupPrims + parcelData.otherPrims + parcelData.selectedPrims; |
753 | updatePacket.ParcelData.UserLocation = parcelData.userLocation; | 753 | updatePacket.ParcelData.UserLocation = parcelData.userLocation; |
754 | updatePacket.ParcelData.UserLookAt = parcelData.userLookAt; | 754 | updatePacket.ParcelData.UserLookAt = parcelData.userLookAt; |
755 | remote_client.OutPacket((Packet)updatePacket); | 755 | remote_client.OutPacket((Packet)updatePacket); |
756 | } | 756 | } |
757 | 757 | ||
758 | public void updateParcelProperties(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client) | 758 | public void updateParcelProperties(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client) |
759 | { | 759 | { |
760 | if (remote_client.AgentId == parcelData.ownerID) | 760 | if (remote_client.AgentId == parcelData.ownerID) |
761 | { | 761 | { |
762 | //Needs later group support | 762 | //Needs later group support |
763 | parcelData.authBuyerID = packet.ParcelData.AuthBuyerID; | 763 | parcelData.authBuyerID = packet.ParcelData.AuthBuyerID; |
764 | parcelData.category = (libsecondlife.Parcel.ParcelCategory)packet.ParcelData.Category; | 764 | parcelData.category = (libsecondlife.Parcel.ParcelCategory)packet.ParcelData.Category; |
765 | parcelData.parcelDesc = Helpers.FieldToUTF8String(packet.ParcelData.Desc); | 765 | parcelData.parcelDesc = Helpers.FieldToUTF8String(packet.ParcelData.Desc); |
766 | parcelData.groupID = packet.ParcelData.GroupID; | 766 | parcelData.groupID = packet.ParcelData.GroupID; |
767 | parcelData.landingType = packet.ParcelData.LandingType; | 767 | parcelData.landingType = packet.ParcelData.LandingType; |
768 | parcelData.mediaAutoScale = packet.ParcelData.MediaAutoScale; | 768 | parcelData.mediaAutoScale = packet.ParcelData.MediaAutoScale; |
769 | parcelData.mediaID = packet.ParcelData.MediaID; | 769 | parcelData.mediaID = packet.ParcelData.MediaID; |
770 | parcelData.mediaURL = Helpers.FieldToUTF8String(packet.ParcelData.MediaURL); | 770 | parcelData.mediaURL = Helpers.FieldToUTF8String(packet.ParcelData.MediaURL); |
771 | parcelData.musicURL = Helpers.FieldToUTF8String(packet.ParcelData.MusicURL); | 771 | parcelData.musicURL = Helpers.FieldToUTF8String(packet.ParcelData.MusicURL); |
772 | parcelData.parcelName = Helpers.FieldToUTF8String(packet.ParcelData.Name); | 772 | parcelData.parcelName = Helpers.FieldToUTF8String(packet.ParcelData.Name); |
773 | parcelData.parcelFlags = packet.ParcelData.ParcelFlags; | 773 | parcelData.parcelFlags = packet.ParcelData.ParcelFlags; |
774 | parcelData.passHours = packet.ParcelData.PassHours; | 774 | parcelData.passHours = packet.ParcelData.PassHours; |
775 | parcelData.passPrice = packet.ParcelData.PassPrice; | 775 | parcelData.passPrice = packet.ParcelData.PassPrice; |
776 | parcelData.salePrice = packet.ParcelData.SalePrice; | 776 | parcelData.salePrice = packet.ParcelData.SalePrice; |
777 | parcelData.snapshotID = packet.ParcelData.SnapshotID; | 777 | parcelData.snapshotID = packet.ParcelData.SnapshotID; |
778 | parcelData.userLocation = packet.ParcelData.UserLocation; | 778 | parcelData.userLocation = packet.ParcelData.UserLocation; |
779 | parcelData.userLookAt = packet.ParcelData.UserLookAt; | 779 | parcelData.userLookAt = packet.ParcelData.UserLookAt; |
780 | sendParcelUpdateToAvatarsOverMe(); | 780 | sendParcelUpdateToAvatarsOverMe(); |
781 | 781 | ||
782 | 782 | ||
783 | } | 783 | } |
784 | } | 784 | } |
785 | 785 | ||
786 | public void sendParcelUpdateToAvatarsOverMe() | 786 | public void sendParcelUpdateToAvatarsOverMe() |
787 | { | 787 | { |
788 | List<Avatar> avatars = m_world.RequestAvatarList(); | 788 | List<Avatar> avatars = m_world.RequestAvatarList(); |
789 | for (int i = 0; i < avatars.Count; i++) | 789 | for (int i = 0; i < avatars.Count; i++) |
790 | { | 790 | { |
791 | Parcel over = m_world.ParcelManager.getParcel((int)Math.Round(avatars[i].Pos.X), (int)Math.Round(avatars[i].Pos.Y)); | 791 | Parcel over = m_world.ParcelManager.getParcel((int)Math.Round(avatars[i].Pos.X), (int)Math.Round(avatars[i].Pos.Y)); |
792 | if (over.parcelData.localID == this.parcelData.localID) | 792 | if (over.parcelData.localID == this.parcelData.localID) |
793 | { | 793 | { |
794 | sendParcelProperties(0, false, 0, avatars[i].ControllingClient); | 794 | sendParcelProperties(0, false, 0, avatars[i].ControllingClient); |
795 | } | 795 | } |
796 | } | 796 | } |
797 | } | 797 | } |
798 | #endregion | 798 | #endregion |
799 | 799 | ||
800 | 800 | ||
801 | #region Update Functions | 801 | #region Update Functions |
802 | /// <summary> | 802 | /// <summary> |
803 | /// Updates the AABBMin and AABBMax values after area/shape modification of parcel | 803 | /// Updates the AABBMin and AABBMax values after area/shape modification of parcel |
804 | /// </summary> | 804 | /// </summary> |
805 | private void updateAABBAndAreaValues() | 805 | private void updateAABBAndAreaValues() |
806 | { | 806 | { |
807 | int min_x = 64; | 807 | int min_x = 64; |
808 | int min_y = 64; | 808 | int min_y = 64; |
809 | int max_x = 0; | 809 | int max_x = 0; |
810 | int max_y = 0; | 810 | int max_y = 0; |
811 | int tempArea = 0; | 811 | int tempArea = 0; |
812 | int x, y; | 812 | int x, y; |
813 | for (x = 0; x < 64; x++) | 813 | for (x = 0; x < 64; x++) |
814 | { | 814 | { |
815 | for (y = 0; y < 64; y++) | 815 | for (y = 0; y < 64; y++) |
816 | { | 816 | { |
817 | if (parcelBitmap[x, y] == true) | 817 | if (parcelBitmap[x, y] == true) |
818 | { | 818 | { |
819 | if (min_x > x) min_x = x; | 819 | if (min_x > x) min_x = x; |
820 | if (min_y > y) min_y = y; | 820 | if (min_y > y) min_y = y; |
821 | if (max_x < x) max_x = x; | 821 | if (max_x < x) max_x = x; |
822 | if (max_y < y) max_y = y; | 822 | if (max_y < y) max_y = y; |
823 | tempArea += 16; //16sqm parcel | 823 | tempArea += 16; //16sqm parcel |
824 | } | 824 | } |
825 | } | 825 | } |
826 | } | 826 | } |
827 | parcelData.AABBMin = new LLVector3((float)(min_x * 4), (float)(min_y * 4), (float)m_world.Terrain.get((min_x * 4), (min_y * 4))); | 827 | parcelData.AABBMin = new LLVector3((float)(min_x * 4), (float)(min_y * 4), (float)m_world.Terrain.get((min_x * 4), (min_y * 4))); |
828 | parcelData.AABBMax = new LLVector3((float)(max_x * 4), (float)(max_y * 4), (float)m_world.Terrain.get((max_x * 4), (max_y * 4))); | 828 | parcelData.AABBMax = new LLVector3((float)(max_x * 4), (float)(max_y * 4), (float)m_world.Terrain.get((max_x * 4), (max_y * 4))); |
829 | parcelData.area = tempArea; | 829 | parcelData.area = tempArea; |
830 | } | 830 | } |
831 | 831 | ||
832 | public void updateParcelBitmapByteArray() | 832 | public void updateParcelBitmapByteArray() |
833 | { | 833 | { |
834 | parcelData.parcelBitmapByteArray = convertParcelBitmapToBytes(); | 834 | parcelData.parcelBitmapByteArray = convertParcelBitmapToBytes(); |
835 | } | 835 | } |
836 | 836 | ||
837 | /// <summary> | 837 | /// <summary> |
838 | /// Update all settings in parcel such as area, bitmap byte array, etc | 838 | /// Update all settings in parcel such as area, bitmap byte array, etc |
839 | /// </summary> | 839 | /// </summary> |
840 | public void forceUpdateParcelInfo() | 840 | public void forceUpdateParcelInfo() |
841 | { | 841 | { |
842 | this.updateAABBAndAreaValues(); | 842 | this.updateAABBAndAreaValues(); |
843 | this.updateParcelBitmapByteArray(); | 843 | this.updateParcelBitmapByteArray(); |
844 | } | 844 | } |
845 | 845 | ||
846 | public void setParcelBitmapFromByteArray() | 846 | public void setParcelBitmapFromByteArray() |
847 | { | 847 | { |
848 | parcelBitmap = convertBytesToParcelBitmap(); | 848 | parcelBitmap = convertBytesToParcelBitmap(); |
849 | } | 849 | } |
850 | #endregion | 850 | #endregion |
851 | 851 | ||
852 | 852 | ||
853 | #region Parcel Bitmap Functions | 853 | #region Parcel Bitmap Functions |
854 | /// <summary> | 854 | /// <summary> |
855 | /// Sets the parcel's bitmap manually | 855 | /// Sets the parcel's bitmap manually |
856 | /// </summary> | 856 | /// </summary> |
857 | /// <param name="bitmap">64x64 block representing where this parcel is on a map</param> | 857 | /// <param name="bitmap">64x64 block representing where this parcel is on a map</param> |
858 | public void setParcelBitmap(bool[,] bitmap) | 858 | public void setParcelBitmap(bool[,] bitmap) |
859 | { | 859 | { |
860 | if (bitmap.GetLength(0) != 64 || bitmap.GetLength(1) != 64 || bitmap.Rank != 2) | 860 | if (bitmap.GetLength(0) != 64 || bitmap.GetLength(1) != 64 || bitmap.Rank != 2) |
861 | { | 861 | { |
862 | //Throw an exception - The bitmap is not 64x64 | 862 | //Throw an exception - The bitmap is not 64x64 |
863 | throw new Exception("Error: Invalid Parcel Bitmap"); | 863 | throw new Exception("Error: Invalid Parcel Bitmap"); |
864 | } | 864 | } |
865 | else | 865 | else |
866 | { | 866 | { |
867 | //Valid: Lets set it | 867 | //Valid: Lets set it |
868 | parcelBitmap = bitmap; | 868 | parcelBitmap = bitmap; |
869 | forceUpdateParcelInfo(); | 869 | forceUpdateParcelInfo(); |
870 | 870 | ||
871 | } | 871 | } |
872 | } | 872 | } |
873 | /// <summary> | 873 | /// <summary> |
874 | /// Gets the parcels bitmap manually | 874 | /// Gets the parcels bitmap manually |
875 | /// </summary> | 875 | /// </summary> |
876 | /// <returns></returns> | 876 | /// <returns></returns> |
877 | public bool[,] getParcelBitmap() | 877 | public bool[,] getParcelBitmap() |
878 | { | 878 | { |
879 | return parcelBitmap; | 879 | return parcelBitmap; |
880 | } | 880 | } |
881 | /// <summary> | 881 | /// <summary> |
882 | /// Converts the parcel bitmap to a packet friendly byte array | 882 | /// Converts the parcel bitmap to a packet friendly byte array |
883 | /// </summary> | 883 | /// </summary> |
884 | /// <returns></returns> | 884 | /// <returns></returns> |
885 | private byte[] convertParcelBitmapToBytes() | 885 | private byte[] convertParcelBitmapToBytes() |
886 | { | 886 | { |
887 | byte[] tempConvertArr = new byte[512]; | 887 | byte[] tempConvertArr = new byte[512]; |
888 | byte tempByte = 0; | 888 | byte tempByte = 0; |
889 | int x, y, i, byteNum = 0; | 889 | int x, y, i, byteNum = 0; |
890 | i = 0; | 890 | i = 0; |
891 | for (y = 0; y < 64; y++) | 891 | for (y = 0; y < 64; y++) |
892 | { | 892 | { |
893 | for (x = 0; x < 64; x++) | 893 | for (x = 0; x < 64; x++) |
894 | { | 894 | { |
895 | tempByte = Convert.ToByte(tempByte | Convert.ToByte(parcelBitmap[x, y]) << (i++ % 8)); | 895 | tempByte = Convert.ToByte(tempByte | Convert.ToByte(parcelBitmap[x, y]) << (i++ % 8)); |
896 | if (i % 8 == 0) | 896 | if (i % 8 == 0) |
897 | { | 897 | { |
898 | tempConvertArr[byteNum] = tempByte; | 898 | tempConvertArr[byteNum] = tempByte; |
899 | tempByte = (byte)0; | 899 | tempByte = (byte)0; |
900 | i = 0; | 900 | i = 0; |
901 | byteNum++; | 901 | byteNum++; |
902 | } | 902 | } |
903 | } | 903 | } |
904 | } | 904 | } |
905 | return tempConvertArr; | 905 | return tempConvertArr; |
906 | } | 906 | } |
907 | 907 | ||
908 | private bool[,] convertBytesToParcelBitmap() | 908 | private bool[,] convertBytesToParcelBitmap() |
909 | { | 909 | { |
910 | bool[,] tempConvertMap = new bool[64, 64]; | 910 | bool[,] tempConvertMap = new bool[64, 64]; |
911 | tempConvertMap.Initialize(); | 911 | tempConvertMap.Initialize(); |
912 | byte tempByte = 0; | 912 | byte tempByte = 0; |
913 | int x = 0, y = 0, i = 0, bitNum = 0; | 913 | int x = 0, y = 0, i = 0, bitNum = 0; |
914 | for (i = 0; i < 512; i++) | 914 | for (i = 0; i < 512; i++) |
915 | { | 915 | { |
916 | tempByte = parcelData.parcelBitmapByteArray[i]; | 916 | tempByte = parcelData.parcelBitmapByteArray[i]; |
917 | for (bitNum = 0; bitNum < 8; bitNum++) | 917 | for (bitNum = 0; bitNum < 8; bitNum++) |
918 | { | 918 | { |
919 | bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte)1); | 919 | bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte)1); |
920 | tempConvertMap[x, y] = bit; | 920 | tempConvertMap[x, y] = bit; |
921 | x++; | 921 | x++; |
922 | if (x > 63) | 922 | if (x > 63) |
923 | { | 923 | { |
924 | x = 0; | 924 | x = 0; |
925 | y++; | 925 | y++; |
926 | } | 926 | } |
927 | 927 | ||
928 | } | 928 | } |
929 | 929 | ||
930 | } | 930 | } |
931 | return tempConvertMap; | 931 | return tempConvertMap; |
932 | } | 932 | } |
933 | /// <summary> | 933 | /// <summary> |
934 | /// Full sim parcel creation | 934 | /// Full sim parcel creation |
935 | /// </summary> | 935 | /// </summary> |
936 | /// <returns></returns> | 936 | /// <returns></returns> |
937 | public static bool[,] basicFullRegionParcelBitmap() | 937 | public static bool[,] basicFullRegionParcelBitmap() |
938 | { | 938 | { |
939 | return getSquareParcelBitmap(0, 0, 256, 256); | 939 | return getSquareParcelBitmap(0, 0, 256, 256); |
940 | } | 940 | } |
941 | 941 | ||
942 | /// <summary> | 942 | /// <summary> |
943 | /// Used to modify the bitmap between the x and y points. Points use 64 scale | 943 | /// Used to modify the bitmap between the x and y points. Points use 64 scale |
944 | /// </summary> | 944 | /// </summary> |
945 | /// <param name="start_x"></param> | 945 | /// <param name="start_x"></param> |
946 | /// <param name="start_y"></param> | 946 | /// <param name="start_y"></param> |
947 | /// <param name="end_x"></param> | 947 | /// <param name="end_x"></param> |
948 | /// <param name="end_y"></param> | 948 | /// <param name="end_y"></param> |
949 | /// <returns></returns> | 949 | /// <returns></returns> |
950 | public static bool[,] getSquareParcelBitmap(int start_x, int start_y, int end_x, int end_y) | 950 | public static bool[,] getSquareParcelBitmap(int start_x, int start_y, int end_x, int end_y) |
951 | { | 951 | { |
952 | 952 | ||
953 | bool[,] tempBitmap = new bool[64, 64]; | 953 | bool[,] tempBitmap = new bool[64, 64]; |
954 | tempBitmap.Initialize(); | 954 | tempBitmap.Initialize(); |
955 | 955 | ||
956 | tempBitmap = modifyParcelBitmapSquare(tempBitmap, start_x, start_y, end_x, end_y, true); | 956 | tempBitmap = modifyParcelBitmapSquare(tempBitmap, start_x, start_y, end_x, end_y, true); |
957 | return tempBitmap; | 957 | return tempBitmap; |
958 | } | 958 | } |
959 | 959 | ||
960 | /// <summary> | 960 | /// <summary> |
961 | /// Change a parcel's bitmap at within a square and set those points to a specific value | 961 | /// Change a parcel's bitmap at within a square and set those points to a specific value |
962 | /// </summary> | 962 | /// </summary> |
963 | /// <param name="parcel_bitmap"></param> | 963 | /// <param name="parcel_bitmap"></param> |
964 | /// <param name="start_x"></param> | 964 | /// <param name="start_x"></param> |
965 | /// <param name="start_y"></param> | 965 | /// <param name="start_y"></param> |
966 | /// <param name="end_x"></param> | 966 | /// <param name="end_x"></param> |
967 | /// <param name="end_y"></param> | 967 | /// <param name="end_y"></param> |
968 | /// <param name="set_value"></param> | 968 | /// <param name="set_value"></param> |
969 | /// <returns></returns> | 969 | /// <returns></returns> |
970 | public static bool[,] modifyParcelBitmapSquare(bool[,] parcel_bitmap, int start_x, int start_y, int end_x, int end_y, bool set_value) | 970 | public static bool[,] modifyParcelBitmapSquare(bool[,] parcel_bitmap, int start_x, int start_y, int end_x, int end_y, bool set_value) |
971 | { | 971 | { |
972 | if (parcel_bitmap.GetLength(0) != 64 || parcel_bitmap.GetLength(1) != 64 || parcel_bitmap.Rank != 2) | 972 | if (parcel_bitmap.GetLength(0) != 64 || parcel_bitmap.GetLength(1) != 64 || parcel_bitmap.Rank != 2) |
973 | { | 973 | { |
974 | //Throw an exception - The bitmap is not 64x64 | 974 | //Throw an exception - The bitmap is not 64x64 |
975 | throw new Exception("Error: Invalid Parcel Bitmap in modifyParcelBitmapSquare()"); | 975 | throw new Exception("Error: Invalid Parcel Bitmap in modifyParcelBitmapSquare()"); |
976 | } | 976 | } |
977 | 977 | ||
978 | int x, y; | 978 | int x, y; |
979 | for (y = 0; y < 64; y++) | 979 | for (y = 0; y < 64; y++) |
980 | { | 980 | { |
981 | for (x = 0; x < 64; x++) | 981 | for (x = 0; x < 64; x++) |
982 | { | 982 | { |
983 | if (x >= start_x / 4 && x < end_x / 4 | 983 | if (x >= start_x / 4 && x < end_x / 4 |
984 | && y >= start_y / 4 && y < end_y / 4) | 984 | && y >= start_y / 4 && y < end_y / 4) |
985 | { | 985 | { |
986 | parcel_bitmap[x, y] = set_value; | 986 | parcel_bitmap[x, y] = set_value; |
987 | } | 987 | } |
988 | } | 988 | } |
989 | } | 989 | } |
990 | return parcel_bitmap; | 990 | return parcel_bitmap; |
991 | } | 991 | } |
992 | /// <summary> | 992 | /// <summary> |
993 | /// Join the true values of 2 bitmaps together | 993 | /// Join the true values of 2 bitmaps together |
994 | /// </summary> | 994 | /// </summary> |
995 | /// <param name="bitmap_base"></param> | 995 | /// <param name="bitmap_base"></param> |
996 | /// <param name="bitmap_add"></param> | 996 | /// <param name="bitmap_add"></param> |
997 | /// <returns></returns> | 997 | /// <returns></returns> |
998 | public static bool[,] mergeParcelBitmaps(bool[,] bitmap_base, bool[,] bitmap_add) | 998 | public static bool[,] mergeParcelBitmaps(bool[,] bitmap_base, bool[,] bitmap_add) |
999 | { | 999 | { |
1000 | if (bitmap_base.GetLength(0) != 64 || bitmap_base.GetLength(1) != 64 || bitmap_base.Rank != 2) | 1000 | if (bitmap_base.GetLength(0) != 64 || bitmap_base.GetLength(1) != 64 || bitmap_base.Rank != 2) |
1001 | { | 1001 | { |
1002 | //Throw an exception - The bitmap is not 64x64 | 1002 | //Throw an exception - The bitmap is not 64x64 |
1003 | throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_base in mergeParcelBitmaps"); | 1003 | throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_base in mergeParcelBitmaps"); |
1004 | } | 1004 | } |
1005 | if (bitmap_add.GetLength(0) != 64 || bitmap_add.GetLength(1) != 64 || bitmap_add.Rank != 2) | 1005 | if (bitmap_add.GetLength(0) != 64 || bitmap_add.GetLength(1) != 64 || bitmap_add.Rank != 2) |
1006 | { | 1006 | { |
1007 | //Throw an exception - The bitmap is not 64x64 | 1007 | //Throw an exception - The bitmap is not 64x64 |
1008 | throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_add in mergeParcelBitmaps"); | 1008 | throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_add in mergeParcelBitmaps"); |
1009 | 1009 | ||
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | int x, y; | 1012 | int x, y; |
1013 | for (y = 0; y < 64; y++) | 1013 | for (y = 0; y < 64; y++) |
1014 | { | 1014 | { |
1015 | for (x = 0; x < 64; x++) | 1015 | for (x = 0; x < 64; x++) |
1016 | { | 1016 | { |
1017 | if (bitmap_add[x, y]) | 1017 | if (bitmap_add[x, y]) |
1018 | { | 1018 | { |
1019 | bitmap_base[x, y] = true; | 1019 | bitmap_base[x, y] = true; |
1020 | } | 1020 | } |
1021 | } | 1021 | } |
1022 | } | 1022 | } |
1023 | return bitmap_base; | 1023 | return bitmap_base; |
1024 | } | 1024 | } |
1025 | #endregion | 1025 | #endregion |
1026 | 1026 | ||
1027 | #region Object Select and Object Owner Listing | 1027 | #region Object Select and Object Owner Listing |
1028 | public void sendForceObjectSelect(int local_id, int request_type, IClientAPI remote_client) | 1028 | public void sendForceObjectSelect(int local_id, int request_type, IClientAPI remote_client) |
1029 | { | 1029 | { |
1030 | List<uint> resultLocalIDs = new List<uint>(); | 1030 | List<uint> resultLocalIDs = new List<uint>(); |
1031 | foreach (SceneObject obj in primsOverMe) | 1031 | foreach (SceneObject obj in primsOverMe) |
1032 | { | 1032 | { |
1033 | if (obj.rootLocalID > 0) | 1033 | if (obj.rootLocalID > 0) |
1034 | { | 1034 | { |
1035 | if (request_type == ParcelManager.PARCEL_SELECT_OBJECTS_OWNER && obj.rootPrimitive.OwnerID == this.parcelData.ownerID) | 1035 | if (request_type == ParcelManager.PARCEL_SELECT_OBJECTS_OWNER && obj.rootPrimitive.OwnerID == this.parcelData.ownerID) |
1036 | { | 1036 | { |
1037 | resultLocalIDs.Add(obj.rootLocalID); | 1037 | resultLocalIDs.Add(obj.rootLocalID); |
1038 | } | 1038 | } |
1039 | else if (request_type == ParcelManager.PARCEL_SELECT_OBJECTS_GROUP && false) //TODO: change false to group support! | 1039 | else if (request_type == ParcelManager.PARCEL_SELECT_OBJECTS_GROUP && false) //TODO: change false to group support! |
1040 | { | 1040 | { |
1041 | 1041 | ||
1042 | } | 1042 | } |
1043 | else if (request_type == ParcelManager.PARCEL_SELECT_OBJECTS_OTHER && obj.rootPrimitive.OwnerID != remote_client.AgentId) | 1043 | else if (request_type == ParcelManager.PARCEL_SELECT_OBJECTS_OTHER && obj.rootPrimitive.OwnerID != remote_client.AgentId) |
1044 | { | 1044 | { |
1045 | resultLocalIDs.Add(obj.rootLocalID); | 1045 | resultLocalIDs.Add(obj.rootLocalID); |
1046 | } | 1046 | } |
1047 | } | 1047 | } |
1048 | } | 1048 | } |
1049 | 1049 | ||
1050 | 1050 | ||
1051 | bool firstCall = true; | 1051 | bool firstCall = true; |
1052 | int MAX_OBJECTS_PER_PACKET = 251; | 1052 | int MAX_OBJECTS_PER_PACKET = 251; |
1053 | ForceObjectSelectPacket pack = new ForceObjectSelectPacket(); | 1053 | ForceObjectSelectPacket pack = new ForceObjectSelectPacket(); |
1054 | ForceObjectSelectPacket.DataBlock[] data; | 1054 | ForceObjectSelectPacket.DataBlock[] data; |
1055 | while (resultLocalIDs.Count > 0) | 1055 | while (resultLocalIDs.Count > 0) |
1056 | { | 1056 | { |
1057 | if (firstCall) | 1057 | if (firstCall) |
1058 | { | 1058 | { |
1059 | pack._Header.ResetList = true; | 1059 | pack._Header.ResetList = true; |
1060 | firstCall = false; | 1060 | firstCall = false; |
1061 | } | 1061 | } |
1062 | else | 1062 | else |
1063 | { | 1063 | { |
1064 | pack._Header.ResetList = false; | 1064 | pack._Header.ResetList = false; |
1065 | } | 1065 | } |
1066 | 1066 | ||
1067 | if (resultLocalIDs.Count > MAX_OBJECTS_PER_PACKET) | 1067 | if (resultLocalIDs.Count > MAX_OBJECTS_PER_PACKET) |
1068 | { | 1068 | { |
1069 | data = new ForceObjectSelectPacket.DataBlock[MAX_OBJECTS_PER_PACKET]; | 1069 | data = new ForceObjectSelectPacket.DataBlock[MAX_OBJECTS_PER_PACKET]; |
1070 | } | 1070 | } |
1071 | else | 1071 | else |
1072 | { | 1072 | { |
1073 | data = new ForceObjectSelectPacket.DataBlock[resultLocalIDs.Count]; | 1073 | data = new ForceObjectSelectPacket.DataBlock[resultLocalIDs.Count]; |
1074 | } | 1074 | } |
1075 | 1075 | ||
1076 | int i; | 1076 | int i; |
1077 | for (i = 0; i < MAX_OBJECTS_PER_PACKET && resultLocalIDs.Count > 0; i++) | 1077 | for (i = 0; i < MAX_OBJECTS_PER_PACKET && resultLocalIDs.Count > 0; i++) |
1078 | { | 1078 | { |
1079 | data[i] = new ForceObjectSelectPacket.DataBlock(); | 1079 | data[i] = new ForceObjectSelectPacket.DataBlock(); |
1080 | data[i].LocalID = Convert.ToUInt32(resultLocalIDs[0]); | 1080 | data[i].LocalID = Convert.ToUInt32(resultLocalIDs[0]); |
1081 | resultLocalIDs.RemoveAt(0); | 1081 | resultLocalIDs.RemoveAt(0); |
1082 | } | 1082 | } |
1083 | pack.Data = data; | 1083 | pack.Data = data; |
1084 | remote_client.OutPacket((Packet)pack); | 1084 | remote_client.OutPacket((Packet)pack); |
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | } | 1087 | } |
1088 | public void sendParcelObjectOwners(IClientAPI remote_client) | 1088 | public void sendParcelObjectOwners(IClientAPI remote_client) |
1089 | { | 1089 | { |
1090 | Dictionary<LLUUID, int> ownersAndCount = new Dictionary<LLUUID,int>(); | 1090 | Dictionary<LLUUID, int> ownersAndCount = new Dictionary<LLUUID,int>(); |
1091 | foreach(SceneObject obj in primsOverMe) | 1091 | foreach(SceneObject obj in primsOverMe) |
1092 | { | 1092 | { |
1093 | if(!ownersAndCount.ContainsKey(obj.rootPrimitive.OwnerID)) | 1093 | if(!ownersAndCount.ContainsKey(obj.rootPrimitive.OwnerID)) |
1094 | { | 1094 | { |
1095 | ownersAndCount.Add(obj.rootPrimitive.OwnerID,0); | 1095 | ownersAndCount.Add(obj.rootPrimitive.OwnerID,0); |
1096 | } | 1096 | } |
1097 | ownersAndCount[obj.rootPrimitive.OwnerID] += obj.primCount; | 1097 | ownersAndCount[obj.rootPrimitive.OwnerID] += obj.primCount; |
1098 | } | 1098 | } |
1099 | if (ownersAndCount.Count > 0) | 1099 | if (ownersAndCount.Count > 0) |
1100 | { | 1100 | { |
1101 | 1101 | ||
1102 | ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock = new ParcelObjectOwnersReplyPacket.DataBlock[32]; | 1102 | ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock = new ParcelObjectOwnersReplyPacket.DataBlock[32]; |
1103 | 1103 | ||
1104 | if(ownersAndCount.Count < 32) | 1104 | if(ownersAndCount.Count < 32) |
1105 | { | 1105 | { |
1106 | dataBlock = new ParcelObjectOwnersReplyPacket.DataBlock[ownersAndCount.Count]; | 1106 | dataBlock = new ParcelObjectOwnersReplyPacket.DataBlock[ownersAndCount.Count]; |
1107 | } | 1107 | } |
1108 | 1108 | ||
1109 | 1109 | ||
1110 | int num = 0; | 1110 | int num = 0; |
1111 | foreach (LLUUID owner in ownersAndCount.Keys) | 1111 | foreach (LLUUID owner in ownersAndCount.Keys) |
1112 | { | 1112 | { |
1113 | dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock(); | 1113 | dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock(); |
1114 | dataBlock[num].Count = ownersAndCount[owner]; | 1114 | dataBlock[num].Count = ownersAndCount[owner]; |
1115 | dataBlock[num].IsGroupOwned = false; //TODO: fix me when group support is added | 1115 | dataBlock[num].IsGroupOwned = false; //TODO: fix me when group support is added |
1116 | dataBlock[num].OnlineStatus = true; //TODO: fix me later | 1116 | dataBlock[num].OnlineStatus = true; //TODO: fix me later |
1117 | dataBlock[num].OwnerID = owner; | 1117 | dataBlock[num].OwnerID = owner; |
1118 | 1118 | ||
1119 | num++; | 1119 | num++; |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | ParcelObjectOwnersReplyPacket pack = new ParcelObjectOwnersReplyPacket(); | 1122 | ParcelObjectOwnersReplyPacket pack = new ParcelObjectOwnersReplyPacket(); |
1123 | pack.Data = dataBlock; | 1123 | pack.Data = dataBlock; |
1124 | remote_client.OutPacket(pack); | 1124 | remote_client.OutPacket(pack); |
1125 | } | 1125 | } |
1126 | } | 1126 | } |
1127 | #endregion | 1127 | #endregion |
1128 | 1128 | ||
1129 | #region Object Returning | 1129 | #region Object Returning |
1130 | public void returnObject(SceneObject obj) | 1130 | public void returnObject(SceneObject obj) |
1131 | { | 1131 | { |
1132 | } | 1132 | } |
1133 | public void returnParcelObjects(int type, LLUUID owner) | 1133 | public void returnParcelObjects(int type, LLUUID owner) |
1134 | { | 1134 | { |
1135 | 1135 | ||
1136 | } | 1136 | } |
1137 | #endregion | 1137 | #endregion |
1138 | 1138 | ||
1139 | #region Object Adding/Removing from Parcel | 1139 | #region Object Adding/Removing from Parcel |
1140 | public void resetParcelPrimCounts() | 1140 | public void resetParcelPrimCounts() |
1141 | { | 1141 | { |
1142 | parcelData.groupPrims = 0; | 1142 | parcelData.groupPrims = 0; |
1143 | parcelData.ownerPrims = 0; | 1143 | parcelData.ownerPrims = 0; |
1144 | parcelData.otherPrims = 0; | 1144 | parcelData.otherPrims = 0; |
1145 | parcelData.selectedPrims = 0; | 1145 | parcelData.selectedPrims = 0; |
1146 | primsOverMe.Clear(); | 1146 | primsOverMe.Clear(); |
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | public void addPrimToCount(SceneObject obj) | 1149 | public void addPrimToCount(SceneObject obj) |
1150 | { | 1150 | { |
1151 | LLUUID prim_owner = obj.rootPrimitive.OwnerID; | 1151 | LLUUID prim_owner = obj.rootPrimitive.OwnerID; |
1152 | int prim_count = obj.primCount; | 1152 | int prim_count = obj.primCount; |
1153 | 1153 | ||
1154 | if (obj.isSelected) | 1154 | if (obj.isSelected) |
1155 | { | 1155 | { |
1156 | parcelData.selectedPrims += prim_count; | 1156 | parcelData.selectedPrims += prim_count; |
1157 | } | 1157 | } |
1158 | else | 1158 | else |
1159 | { | 1159 | { |
1160 | if (prim_owner == parcelData.ownerID) | 1160 | if (prim_owner == parcelData.ownerID) |
1161 | { | 1161 | { |
1162 | parcelData.ownerPrims += prim_count; | 1162 | parcelData.ownerPrims += prim_count; |
1163 | } | 1163 | } |
1164 | else | 1164 | else |
1165 | { | 1165 | { |
1166 | parcelData.otherPrims += prim_count; | 1166 | parcelData.otherPrims += prim_count; |
1167 | } | 1167 | } |
1168 | } | 1168 | } |
1169 | 1169 | ||
1170 | primsOverMe.Add(obj); | 1170 | primsOverMe.Add(obj); |
1171 | 1171 | ||
1172 | } | 1172 | } |
1173 | 1173 | ||
1174 | public void removePrimFromCount(SceneObject obj) | 1174 | public void removePrimFromCount(SceneObject obj) |
1175 | { | 1175 | { |
1176 | if (primsOverMe.Contains(obj)) | 1176 | if (primsOverMe.Contains(obj)) |
1177 | { | 1177 | { |
1178 | LLUUID prim_owner = obj.rootPrimitive.OwnerID; | 1178 | LLUUID prim_owner = obj.rootPrimitive.OwnerID; |
1179 | int prim_count = obj.primCount; | 1179 | int prim_count = obj.primCount; |
1180 | 1180 | ||
1181 | if (prim_owner == parcelData.ownerID) | 1181 | if (prim_owner == parcelData.ownerID) |
1182 | { | 1182 | { |
1183 | parcelData.ownerPrims -= prim_count; | 1183 | parcelData.ownerPrims -= prim_count; |
1184 | } | 1184 | } |
1185 | else if (prim_owner == parcelData.groupID) | 1185 | else if (prim_owner == parcelData.groupID) |
1186 | { | 1186 | { |
1187 | parcelData.groupPrims -= prim_count; | 1187 | parcelData.groupPrims -= prim_count; |
1188 | } | 1188 | } |
1189 | else | 1189 | else |
1190 | { | 1190 | { |
1191 | parcelData.otherPrims -= prim_count; | 1191 | parcelData.otherPrims -= prim_count; |
1192 | } | 1192 | } |
1193 | 1193 | ||
1194 | primsOverMe.Remove(obj); | 1194 | primsOverMe.Remove(obj); |
1195 | } | 1195 | } |
1196 | } | 1196 | } |
1197 | #endregion | 1197 | #endregion |
1198 | 1198 | ||
1199 | #endregion | 1199 | #endregion |
1200 | 1200 | ||
1201 | 1201 | ||
1202 | } | 1202 | } |
1203 | #endregion | 1203 | #endregion |
1204 | 1204 | ||
1205 | 1205 | ||
1206 | } | 1206 | } |
diff --git a/OpenSim/Region/Environment/RegionManager.cs b/OpenSim/Region/Environment/RegionManager.cs index cd67e97..35fbf45 100644 --- a/OpenSim/Region/Environment/RegionManager.cs +++ b/OpenSim/Region/Environment/RegionManager.cs | |||
@@ -1,29 +1,29 @@ | |||
1 | using System.Collections.Generic; | 1 | using System.Collections.Generic; |
2 | using OpenSim.Framework; | 2 | using OpenSim.Framework; |
3 | using OpenSim.Framework.Communications; | 3 | using OpenSim.Framework.Communications; |
4 | using OpenSim.Framework.Servers; | 4 | using OpenSim.Framework.Servers; |
5 | using OpenSim.Region.Capabilities; | 5 | using OpenSim.Region.Capabilities; |
6 | using OpenSim.Region.Environment.Scenes; | 6 | using OpenSim.Region.Environment.Scenes; |
7 | 7 | ||
8 | namespace OpenSim.Region.Environment | 8 | namespace OpenSim.Region.Environment |
9 | { | 9 | { |
10 | public class RegionManager //needs renaming , but first we need to rename the namespace | 10 | public class RegionManager //needs renaming , but first we need to rename the namespace |
11 | { | 11 | { |
12 | protected AuthenticateSessionsBase authenticateHandler; | 12 | protected AuthenticateSessionsBase authenticateHandler; |
13 | protected RegionCommsListener regionCommsHost; | 13 | protected RegionCommsListener regionCommsHost; |
14 | protected CommunicationsManager commsManager; | 14 | protected CommunicationsManager commsManager; |
15 | protected List<Caps> capsHandlers = new List<Caps>(); | 15 | protected List<Caps> capsHandlers = new List<Caps>(); |
16 | protected BaseHttpServer httpListener; | 16 | protected BaseHttpServer httpListener; |
17 | 17 | ||
18 | protected Scene m_Scene; | 18 | protected Scene m_Scene; |
19 | 19 | ||
20 | public ParcelManager parcelManager; | 20 | public ParcelManager parcelManager; |
21 | public EstateManager estateManager; | 21 | public EstateManager estateManager; |
22 | 22 | ||
23 | public RegionManager() | 23 | public RegionManager() |
24 | { | 24 | { |
25 | 25 | ||
26 | } | 26 | } |
27 | 27 | ||
28 | } | 28 | } |
29 | } | 29 | } |
diff --git a/OpenSim/Region/Environment/Scenes/Entity.cs b/OpenSim/Region/Environment/Scenes/Entity.cs index 084c9ab..2456a4e 100644 --- a/OpenSim/Region/Environment/Scenes/Entity.cs +++ b/OpenSim/Region/Environment/Scenes/Entity.cs | |||
@@ -1,115 +1,115 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using libsecondlife; | 29 | using libsecondlife; |
30 | using OpenSim.Physics.Manager; | 30 | using OpenSim.Physics.Manager; |
31 | 31 | ||
32 | namespace OpenSim.Region.Environment.Scenes | 32 | namespace OpenSim.Region.Environment.Scenes |
33 | { | 33 | { |
34 | public abstract class Entity :EntityBase //this class (Entity) will be phased out | 34 | public abstract class Entity :EntityBase //this class (Entity) will be phased out |
35 | { | 35 | { |
36 | protected PhysicsActor _physActor; | 36 | protected PhysicsActor _physActor; |
37 | 37 | ||
38 | /// <summary> | 38 | /// <summary> |
39 | /// | 39 | /// |
40 | /// </summary> | 40 | /// </summary> |
41 | public override LLVector3 Pos | 41 | public override LLVector3 Pos |
42 | { | 42 | { |
43 | get | 43 | get |
44 | { | 44 | { |
45 | if (this._physActor != null) | 45 | if (this._physActor != null) |
46 | { | 46 | { |
47 | m_pos.X = _physActor.Position.X; | 47 | m_pos.X = _physActor.Position.X; |
48 | m_pos.Y = _physActor.Position.Y; | 48 | m_pos.Y = _physActor.Position.Y; |
49 | m_pos.Z = _physActor.Position.Z; | 49 | m_pos.Z = _physActor.Position.Z; |
50 | } | 50 | } |
51 | 51 | ||
52 | return m_pos; | 52 | return m_pos; |
53 | } | 53 | } |
54 | set | 54 | set |
55 | { | 55 | { |
56 | if (this._physActor != null) | 56 | if (this._physActor != null) |
57 | { | 57 | { |
58 | try | 58 | try |
59 | { | 59 | { |
60 | lock (this.m_world.SyncRoot) | 60 | lock (this.m_world.SyncRoot) |
61 | { | 61 | { |
62 | 62 | ||
63 | this._physActor.Position = new PhysicsVector(value.X, value.Y, value.Z); | 63 | this._physActor.Position = new PhysicsVector(value.X, value.Y, value.Z); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | catch (Exception e) | 66 | catch (Exception e) |
67 | { | 67 | { |
68 | Console.WriteLine(e.Message); | 68 | Console.WriteLine(e.Message); |
69 | } | 69 | } |
70 | } | 70 | } |
71 | 71 | ||
72 | m_pos = value; | 72 | m_pos = value; |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | 76 | ||
77 | /// <summary> | 77 | /// <summary> |
78 | /// | 78 | /// |
79 | /// </summary> | 79 | /// </summary> |
80 | public override LLVector3 Velocity | 80 | public override LLVector3 Velocity |
81 | { | 81 | { |
82 | get | 82 | get |
83 | { | 83 | { |
84 | if (this._physActor != null) | 84 | if (this._physActor != null) |
85 | { | 85 | { |
86 | m_velocity.X = _physActor.Velocity.X; | 86 | m_velocity.X = _physActor.Velocity.X; |
87 | m_velocity.Y = _physActor.Velocity.Y; | 87 | m_velocity.Y = _physActor.Velocity.Y; |
88 | m_velocity.Z = _physActor.Velocity.Z; | 88 | m_velocity.Z = _physActor.Velocity.Z; |
89 | } | 89 | } |
90 | 90 | ||
91 | return m_velocity; | 91 | return m_velocity; |
92 | } | 92 | } |
93 | set | 93 | set |
94 | { | 94 | { |
95 | if (this._physActor != null) | 95 | if (this._physActor != null) |
96 | { | 96 | { |
97 | try | 97 | try |
98 | { | 98 | { |
99 | lock (this.m_world.SyncRoot) | 99 | lock (this.m_world.SyncRoot) |
100 | { | 100 | { |
101 | 101 | ||
102 | this._physActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); | 102 | this._physActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | catch (Exception e) | 105 | catch (Exception e) |
106 | { | 106 | { |
107 | Console.WriteLine(e.Message); | 107 | Console.WriteLine(e.Message); |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | m_velocity = value; | 111 | m_velocity = value; |
112 | } | 112 | } |
113 | } | 113 | } |
114 | } | 114 | } |
115 | } | 115 | } |
diff --git a/OpenSim/Region/Environment/Scenes/EntityBase.cs b/OpenSim/Region/Environment/Scenes/EntityBase.cs index 65a0395..04cf595 100644 --- a/OpenSim/Region/Environment/Scenes/EntityBase.cs +++ b/OpenSim/Region/Environment/Scenes/EntityBase.cs | |||
@@ -1,142 +1,142 @@ | |||
1 | using System.Collections.Generic; | 1 | using System.Collections.Generic; |
2 | using Axiom.Math; | 2 | using Axiom.Math; |
3 | using libsecondlife; | 3 | using libsecondlife; |
4 | 4 | ||
5 | namespace OpenSim.Region.Environment.Scenes | 5 | namespace OpenSim.Region.Environment.Scenes |
6 | { | 6 | { |
7 | public abstract class EntityBase | 7 | public abstract class EntityBase |
8 | { | 8 | { |
9 | public LLUUID uuid; | 9 | public LLUUID uuid; |
10 | 10 | ||
11 | protected List<EntityBase> children; | 11 | protected List<EntityBase> children; |
12 | 12 | ||
13 | protected Scene m_world; | 13 | protected Scene m_world; |
14 | protected string m_name; | 14 | protected string m_name; |
15 | 15 | ||
16 | /// <summary> | 16 | /// <summary> |
17 | /// | 17 | /// |
18 | /// </summary> | 18 | /// </summary> |
19 | public virtual string Name | 19 | public virtual string Name |
20 | { | 20 | { |
21 | get { return m_name; } | 21 | get { return m_name; } |
22 | set { m_name = value; } | 22 | set { m_name = value; } |
23 | } | 23 | } |
24 | 24 | ||
25 | protected LLVector3 m_pos; | 25 | protected LLVector3 m_pos; |
26 | /// <summary> | 26 | /// <summary> |
27 | /// | 27 | /// |
28 | /// </summary> | 28 | /// </summary> |
29 | public virtual LLVector3 Pos | 29 | public virtual LLVector3 Pos |
30 | { | 30 | { |
31 | get | 31 | get |
32 | { | 32 | { |
33 | return m_pos; | 33 | return m_pos; |
34 | } | 34 | } |
35 | set | 35 | set |
36 | { | 36 | { |
37 | m_pos = value; | 37 | m_pos = value; |
38 | } | 38 | } |
39 | } | 39 | } |
40 | 40 | ||
41 | public LLVector3 m_velocity; | 41 | public LLVector3 m_velocity; |
42 | 42 | ||
43 | /// <summary> | 43 | /// <summary> |
44 | /// | 44 | /// |
45 | /// </summary> | 45 | /// </summary> |
46 | public virtual LLVector3 Velocity | 46 | public virtual LLVector3 Velocity |
47 | { | 47 | { |
48 | get | 48 | get |
49 | { | 49 | { |
50 | return m_velocity; | 50 | return m_velocity; |
51 | } | 51 | } |
52 | set | 52 | set |
53 | { | 53 | { |
54 | m_velocity = value; | 54 | m_velocity = value; |
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | protected Quaternion m_rotation = new Quaternion(0,0,1,0); | 58 | protected Quaternion m_rotation = new Quaternion(0,0,1,0); |
59 | 59 | ||
60 | public virtual Quaternion Rotation | 60 | public virtual Quaternion Rotation |
61 | { | 61 | { |
62 | get | 62 | get |
63 | { | 63 | { |
64 | return m_rotation; | 64 | return m_rotation; |
65 | } | 65 | } |
66 | set | 66 | set |
67 | { | 67 | { |
68 | m_rotation = value; | 68 | m_rotation = value; |
69 | } | 69 | } |
70 | } | 70 | } |
71 | 71 | ||
72 | protected uint m_localId; | 72 | protected uint m_localId; |
73 | 73 | ||
74 | public uint LocalId | 74 | public uint LocalId |
75 | { | 75 | { |
76 | get { return m_localId; } | 76 | get { return m_localId; } |
77 | set { m_localId = value; } | 77 | set { m_localId = value; } |
78 | } | 78 | } |
79 | 79 | ||
80 | /// <summary> | 80 | /// <summary> |
81 | /// Creates a new Entity (should not occur on it's own) | 81 | /// Creates a new Entity (should not occur on it's own) |
82 | /// </summary> | 82 | /// </summary> |
83 | public EntityBase() | 83 | public EntityBase() |
84 | { | 84 | { |
85 | uuid = new LLUUID(); | 85 | uuid = new LLUUID(); |
86 | 86 | ||
87 | m_pos = new LLVector3(); | 87 | m_pos = new LLVector3(); |
88 | m_velocity = new LLVector3(); | 88 | m_velocity = new LLVector3(); |
89 | Rotation = new Quaternion(); | 89 | Rotation = new Quaternion(); |
90 | m_name = "(basic entity)"; | 90 | m_name = "(basic entity)"; |
91 | children = new List<EntityBase>(); | 91 | children = new List<EntityBase>(); |
92 | } | 92 | } |
93 | 93 | ||
94 | /// <summary> | 94 | /// <summary> |
95 | /// | 95 | /// |
96 | /// </summary> | 96 | /// </summary> |
97 | public virtual void updateMovement() | 97 | public virtual void updateMovement() |
98 | { | 98 | { |
99 | foreach (EntityBase child in children) | 99 | foreach (EntityBase child in children) |
100 | { | 100 | { |
101 | child.updateMovement(); | 101 | child.updateMovement(); |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | /// <summary> | 105 | /// <summary> |
106 | /// Performs any updates that need to be done at each frame. This function is overridable from it's children. | 106 | /// Performs any updates that need to be done at each frame. This function is overridable from it's children. |
107 | /// </summary> | 107 | /// </summary> |
108 | public virtual void update() | 108 | public virtual void update() |
109 | { | 109 | { |
110 | // Do any per-frame updates needed that are applicable to every type of entity | 110 | // Do any per-frame updates needed that are applicable to every type of entity |
111 | foreach (EntityBase child in children) | 111 | foreach (EntityBase child in children) |
112 | { | 112 | { |
113 | child.update(); | 113 | child.update(); |
114 | } | 114 | } |
115 | } | 115 | } |
116 | 116 | ||
117 | /// <summary> | 117 | /// <summary> |
118 | /// Called at a set interval to inform entities that they should back themsleves up to the DB | 118 | /// Called at a set interval to inform entities that they should back themsleves up to the DB |
119 | /// </summary> | 119 | /// </summary> |
120 | public virtual void BackUp() | 120 | public virtual void BackUp() |
121 | { | 121 | { |
122 | 122 | ||
123 | } | 123 | } |
124 | 124 | ||
125 | /// <summary> | 125 | /// <summary> |
126 | /// Copies the entity | 126 | /// Copies the entity |
127 | /// </summary> | 127 | /// </summary> |
128 | /// <returns></returns> | 128 | /// <returns></returns> |
129 | public virtual EntityBase Copy() | 129 | public virtual EntityBase Copy() |
130 | { | 130 | { |
131 | return (EntityBase)this.MemberwiseClone(); | 131 | return (EntityBase)this.MemberwiseClone(); |
132 | } | 132 | } |
133 | 133 | ||
134 | /// <summary> | 134 | /// <summary> |
135 | /// Infoms the entity that the land (heightmap) has changed | 135 | /// Infoms the entity that the land (heightmap) has changed |
136 | /// </summary> | 136 | /// </summary> |
137 | public virtual void LandRenegerated() | 137 | public virtual void LandRenegerated() |
138 | { | 138 | { |
139 | 139 | ||
140 | } | 140 | } |
141 | } | 141 | } |
142 | } | 142 | } |
diff --git a/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs index 7c3a033..8551b70 100644 --- a/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs +++ b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs | |||
@@ -1,14 +1,14 @@ | |||
1 | using libsecondlife; | 1 | using libsecondlife; |
2 | using libsecondlife.Packets; | 2 | using libsecondlife.Packets; |
3 | using OpenSim.Framework.Interfaces; | 3 | using OpenSim.Framework.Interfaces; |
4 | 4 | ||
5 | namespace OpenSim.Region.Environment.Scenes | 5 | namespace OpenSim.Region.Environment.Scenes |
6 | { | 6 | { |
7 | public interface IScenePresenceBody | 7 | public interface IScenePresenceBody |
8 | { | 8 | { |
9 | void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation); | 9 | void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation); |
10 | void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam); | 10 | void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam); |
11 | void SendOurAppearance(IClientAPI OurClient); | 11 | void SendOurAppearance(IClientAPI OurClient); |
12 | void SendAppearanceToOtherAgent(ScenePresence avatarInfo); | 12 | void SendAppearanceToOtherAgent(ScenePresence avatarInfo); |
13 | } | 13 | } |
14 | } | 14 | } |
diff --git a/OpenSim/Region/Environment/Scenes/Primitive.cs b/OpenSim/Region/Environment/Scenes/Primitive.cs index 0e5b083..b413758 100644 --- a/OpenSim/Region/Environment/Scenes/Primitive.cs +++ b/OpenSim/Region/Environment/Scenes/Primitive.cs | |||
@@ -1,648 +1,648 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using Axiom.Math; | 3 | using Axiom.Math; |
4 | using libsecondlife; | 4 | using libsecondlife; |
5 | using libsecondlife.Packets; | 5 | using libsecondlife.Packets; |
6 | using OpenSim.Framework.Interfaces; | 6 | using OpenSim.Framework.Interfaces; |
7 | using OpenSim.Framework.Inventory; | 7 | using OpenSim.Framework.Inventory; |
8 | using OpenSim.Framework.Types; | 8 | using OpenSim.Framework.Types; |
9 | 9 | ||
10 | namespace OpenSim.Region.Environment.Scenes | 10 | namespace OpenSim.Region.Environment.Scenes |
11 | { | 11 | { |
12 | public delegate void PrimCountTaintedDelegate(); | 12 | public delegate void PrimCountTaintedDelegate(); |
13 | 13 | ||
14 | public class Primitive : EntityBase | 14 | public class Primitive : EntityBase |
15 | { | 15 | { |
16 | private const uint FULL_MASK_PERMISSIONS = 2147483647; | 16 | private const uint FULL_MASK_PERMISSIONS = 2147483647; |
17 | 17 | ||
18 | private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); | 18 | private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); |
19 | private ulong m_regionHandle; | 19 | private ulong m_regionHandle; |
20 | private byte updateFlag = 0; | 20 | private byte updateFlag = 0; |
21 | private uint m_flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128; | 21 | private uint m_flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128; |
22 | 22 | ||
23 | private Dictionary<LLUUID, InventoryItem> inventoryItems; | 23 | private Dictionary<LLUUID, InventoryItem> inventoryItems; |
24 | 24 | ||
25 | private string m_description = ""; | 25 | private string m_description = ""; |
26 | 26 | ||
27 | public string SitName = ""; | 27 | public string SitName = ""; |
28 | public string TouchName = ""; | 28 | public string TouchName = ""; |
29 | public string Text = ""; | 29 | public string Text = ""; |
30 | 30 | ||
31 | public LLUUID CreatorID; | 31 | public LLUUID CreatorID; |
32 | public LLUUID OwnerID; | 32 | public LLUUID OwnerID; |
33 | public LLUUID LastOwnerID; | 33 | public LLUUID LastOwnerID; |
34 | public Int32 CreationDate; | 34 | public Int32 CreationDate; |
35 | 35 | ||
36 | public uint ParentID = 0; | 36 | public uint ParentID = 0; |
37 | 37 | ||
38 | public uint OwnerMask = FULL_MASK_PERMISSIONS; | 38 | public uint OwnerMask = FULL_MASK_PERMISSIONS; |
39 | public uint NextOwnerMask = FULL_MASK_PERMISSIONS; | 39 | public uint NextOwnerMask = FULL_MASK_PERMISSIONS; |
40 | public uint GroupMask = FULL_MASK_PERMISSIONS; | 40 | public uint GroupMask = FULL_MASK_PERMISSIONS; |
41 | public uint EveryoneMask = FULL_MASK_PERMISSIONS; | 41 | public uint EveryoneMask = FULL_MASK_PERMISSIONS; |
42 | public uint BaseMask = FULL_MASK_PERMISSIONS; | 42 | public uint BaseMask = FULL_MASK_PERMISSIONS; |
43 | 43 | ||
44 | private PrimitiveBaseShape m_Shape; | 44 | private PrimitiveBaseShape m_Shape; |
45 | 45 | ||
46 | public SceneObject m_RootParent; | 46 | public SceneObject m_RootParent; |
47 | public bool m_isRootPrim; | 47 | public bool m_isRootPrim; |
48 | public EntityBase m_Parent; | 48 | public EntityBase m_Parent; |
49 | 49 | ||
50 | private EventManager m_eventManager; | 50 | private EventManager m_eventManager; |
51 | 51 | ||
52 | public event PrimCountTaintedDelegate OnPrimCountTainted; | 52 | public event PrimCountTaintedDelegate OnPrimCountTainted; |
53 | 53 | ||
54 | #region Properties | 54 | #region Properties |
55 | /// <summary> | 55 | /// <summary> |
56 | /// If rootprim, will return world position | 56 | /// If rootprim, will return world position |
57 | /// otherwise will return local offset from rootprim | 57 | /// otherwise will return local offset from rootprim |
58 | /// </summary> | 58 | /// </summary> |
59 | public override LLVector3 Pos | 59 | public override LLVector3 Pos |
60 | { | 60 | { |
61 | get | 61 | get |
62 | { | 62 | { |
63 | if (m_isRootPrim) | 63 | if (m_isRootPrim) |
64 | { | 64 | { |
65 | //if we are rootprim then our offset should be zero | 65 | //if we are rootprim then our offset should be zero |
66 | return this.m_pos + m_Parent.Pos; | 66 | return this.m_pos + m_Parent.Pos; |
67 | } | 67 | } |
68 | else | 68 | else |
69 | { | 69 | { |
70 | return this.m_pos; | 70 | return this.m_pos; |
71 | } | 71 | } |
72 | } | 72 | } |
73 | set | 73 | set |
74 | { | 74 | { |
75 | if (m_isRootPrim) | 75 | if (m_isRootPrim) |
76 | { | 76 | { |
77 | m_Parent.Pos = value; | 77 | m_Parent.Pos = value; |
78 | } | 78 | } |
79 | this.m_pos = value - m_Parent.Pos; | 79 | this.m_pos = value - m_Parent.Pos; |
80 | } | 80 | } |
81 | 81 | ||
82 | } | 82 | } |
83 | 83 | ||
84 | public PrimitiveBaseShape Shape | 84 | public PrimitiveBaseShape Shape |
85 | { | 85 | { |
86 | get | 86 | get |
87 | { | 87 | { |
88 | return this.m_Shape; | 88 | return this.m_Shape; |
89 | } | 89 | } |
90 | } | 90 | } |
91 | 91 | ||
92 | public LLVector3 WorldPos | 92 | public LLVector3 WorldPos |
93 | { | 93 | { |
94 | get | 94 | get |
95 | { | 95 | { |
96 | if (!this.m_isRootPrim) | 96 | if (!this.m_isRootPrim) |
97 | { | 97 | { |
98 | Primitive parentPrim = (Primitive)this.m_Parent; | 98 | Primitive parentPrim = (Primitive)this.m_Parent; |
99 | Axiom.Math.Vector3 offsetPos = new Vector3(this.m_pos.X, this.m_pos.Y, this.m_pos.Z); | 99 | Axiom.Math.Vector3 offsetPos = new Vector3(this.m_pos.X, this.m_pos.Y, this.m_pos.Z); |
100 | offsetPos = parentPrim.Rotation * offsetPos; | 100 | offsetPos = parentPrim.Rotation * offsetPos; |
101 | return parentPrim.WorldPos + new LLVector3(offsetPos.x, offsetPos.y, offsetPos.z); | 101 | return parentPrim.WorldPos + new LLVector3(offsetPos.x, offsetPos.y, offsetPos.z); |
102 | } | 102 | } |
103 | else | 103 | else |
104 | { | 104 | { |
105 | return this.Pos; | 105 | return this.Pos; |
106 | } | 106 | } |
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
110 | public string Description | 110 | public string Description |
111 | { | 111 | { |
112 | get | 112 | get |
113 | { | 113 | { |
114 | return this.m_description; | 114 | return this.m_description; |
115 | } | 115 | } |
116 | set | 116 | set |
117 | { | 117 | { |
118 | this.m_description = value; | 118 | this.m_description = value; |
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | public LLVector3 Scale | 122 | public LLVector3 Scale |
123 | { | 123 | { |
124 | set | 124 | set |
125 | { | 125 | { |
126 | this.m_Shape.Scale = value; | 126 | this.m_Shape.Scale = value; |
127 | } | 127 | } |
128 | get | 128 | get |
129 | { | 129 | { |
130 | return this.m_Shape.Scale; | 130 | return this.m_Shape.Scale; |
131 | } | 131 | } |
132 | } | 132 | } |
133 | #endregion | 133 | #endregion |
134 | 134 | ||
135 | #region Constructors | 135 | #region Constructors |
136 | /// <summary> | 136 | /// <summary> |
137 | /// | 137 | /// |
138 | /// </summary> | 138 | /// </summary> |
139 | /// <param name="regionHandle"></param> | 139 | /// <param name="regionHandle"></param> |
140 | /// <param name="world"></param> | 140 | /// <param name="world"></param> |
141 | /// <param name="addPacket"></param> | 141 | /// <param name="addPacket"></param> |
142 | /// <param name="ownerID"></param> | 142 | /// <param name="ownerID"></param> |
143 | /// <param name="localID"></param> | 143 | /// <param name="localID"></param> |
144 | /// <param name="isRoot"></param> | 144 | /// <param name="isRoot"></param> |
145 | /// <param name="parent"></param> | 145 | /// <param name="parent"></param> |
146 | /// <param name="rootObject"></param> | 146 | /// <param name="rootObject"></param> |
147 | public Primitive(ulong regionHandle, Scene world, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, SceneObject rootObject, PrimitiveBaseShape shape, LLVector3 pos) | 147 | public Primitive(ulong regionHandle, Scene world, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, SceneObject rootObject, PrimitiveBaseShape shape, LLVector3 pos) |
148 | { | 148 | { |
149 | 149 | ||
150 | m_regionHandle = regionHandle; | 150 | m_regionHandle = regionHandle; |
151 | m_world = world; | 151 | m_world = world; |
152 | inventoryItems = new Dictionary<LLUUID, InventoryItem>(); | 152 | inventoryItems = new Dictionary<LLUUID, InventoryItem>(); |
153 | this.m_Parent = parent; | 153 | this.m_Parent = parent; |
154 | this.m_isRootPrim = isRoot; | 154 | this.m_isRootPrim = isRoot; |
155 | this.m_RootParent = rootObject; | 155 | this.m_RootParent = rootObject; |
156 | this.CreateFromShape(ownerID, localID, pos, shape); | 156 | this.CreateFromShape(ownerID, localID, pos, shape); |
157 | this.Rotation = Axiom.Math.Quaternion.Identity; | 157 | this.Rotation = Axiom.Math.Quaternion.Identity; |
158 | 158 | ||
159 | m_world.AcknowledgeNewPrim(this); | 159 | m_world.AcknowledgeNewPrim(this); |
160 | 160 | ||
161 | this.OnPrimCountTainted(); | 161 | this.OnPrimCountTainted(); |
162 | } | 162 | } |
163 | 163 | ||
164 | /// <summary> | 164 | /// <summary> |
165 | /// | 165 | /// |
166 | /// </summary> | 166 | /// </summary> |
167 | /// <remarks>Empty constructor for duplication</remarks> | 167 | /// <remarks>Empty constructor for duplication</remarks> |
168 | public Primitive() | 168 | public Primitive() |
169 | { | 169 | { |
170 | 170 | ||
171 | } | 171 | } |
172 | 172 | ||
173 | #endregion | 173 | #endregion |
174 | 174 | ||
175 | #region Destructors | 175 | #region Destructors |
176 | 176 | ||
177 | ~Primitive() | 177 | ~Primitive() |
178 | { | 178 | { |
179 | this.OnPrimCountTainted(); | 179 | this.OnPrimCountTainted(); |
180 | } | 180 | } |
181 | #endregion | 181 | #endregion |
182 | 182 | ||
183 | #region Duplication | 183 | #region Duplication |
184 | 184 | ||
185 | public Primitive Copy(EntityBase parent, SceneObject rootParent) | 185 | public Primitive Copy(EntityBase parent, SceneObject rootParent) |
186 | { | 186 | { |
187 | Primitive dupe = (Primitive)this.MemberwiseClone(); | 187 | Primitive dupe = (Primitive)this.MemberwiseClone(); |
188 | 188 | ||
189 | dupe.m_Parent = parent; | 189 | dupe.m_Parent = parent; |
190 | dupe.m_RootParent = rootParent; | 190 | dupe.m_RootParent = rootParent; |
191 | 191 | ||
192 | // TODO: Copy this properly. | 192 | // TODO: Copy this properly. |
193 | dupe.inventoryItems = this.inventoryItems; | 193 | dupe.inventoryItems = this.inventoryItems; |
194 | dupe.children = new List<EntityBase>(); | 194 | dupe.children = new List<EntityBase>(); |
195 | dupe.m_Shape = this.m_Shape.Copy(); | 195 | dupe.m_Shape = this.m_Shape.Copy(); |
196 | dupe.m_regionHandle = this.m_regionHandle; | 196 | dupe.m_regionHandle = this.m_regionHandle; |
197 | dupe.m_world = this.m_world; | 197 | dupe.m_world = this.m_world; |
198 | 198 | ||
199 | uint newLocalID = this.m_world.PrimIDAllocate(); | 199 | uint newLocalID = this.m_world.PrimIDAllocate(); |
200 | dupe.uuid = LLUUID.Random(); | 200 | dupe.uuid = LLUUID.Random(); |
201 | dupe.LocalId = newLocalID; | 201 | dupe.LocalId = newLocalID; |
202 | 202 | ||
203 | if (parent is SceneObject) | 203 | if (parent is SceneObject) |
204 | { | 204 | { |
205 | dupe.m_isRootPrim = true; | 205 | dupe.m_isRootPrim = true; |
206 | dupe.ParentID = 0; | 206 | dupe.ParentID = 0; |
207 | } | 207 | } |
208 | else | 208 | else |
209 | { | 209 | { |
210 | dupe.m_isRootPrim = false; | 210 | dupe.m_isRootPrim = false; |
211 | dupe.ParentID = ((Primitive)parent).LocalId; | 211 | dupe.ParentID = ((Primitive)parent).LocalId; |
212 | } | 212 | } |
213 | 213 | ||
214 | dupe.Scale = new LLVector3(this.Scale.X, this.Scale.Y, this.Scale.Z); | 214 | dupe.Scale = new LLVector3(this.Scale.X, this.Scale.Y, this.Scale.Z); |
215 | dupe.Rotation = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z); | 215 | dupe.Rotation = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z); |
216 | dupe.m_pos = new LLVector3(this.m_pos.X, this.m_pos.Y, this.m_pos.Z); | 216 | dupe.m_pos = new LLVector3(this.m_pos.X, this.m_pos.Y, this.m_pos.Z); |
217 | 217 | ||
218 | rootParent.AddChildToList(dupe); | 218 | rootParent.AddChildToList(dupe); |
219 | this.m_world.AcknowledgeNewPrim(dupe); | 219 | this.m_world.AcknowledgeNewPrim(dupe); |
220 | dupe.TriggerOnPrimCountTainted(); | 220 | dupe.TriggerOnPrimCountTainted(); |
221 | 221 | ||
222 | foreach (Primitive prim in this.children) | 222 | foreach (Primitive prim in this.children) |
223 | { | 223 | { |
224 | Primitive primClone = prim.Copy(dupe, rootParent); | 224 | Primitive primClone = prim.Copy(dupe, rootParent); |
225 | dupe.children.Add(primClone); | 225 | dupe.children.Add(primClone); |
226 | } | 226 | } |
227 | 227 | ||
228 | return dupe; | 228 | return dupe; |
229 | } | 229 | } |
230 | 230 | ||
231 | #endregion | 231 | #endregion |
232 | 232 | ||
233 | #region Override from EntityBase | 233 | #region Override from EntityBase |
234 | /// <summary> | 234 | /// <summary> |
235 | /// | 235 | /// |
236 | /// </summary> | 236 | /// </summary> |
237 | public override void update() | 237 | public override void update() |
238 | { | 238 | { |
239 | if (this.updateFlag == 1) // is a new prim just been created/reloaded or has major changes | 239 | if (this.updateFlag == 1) // is a new prim just been created/reloaded or has major changes |
240 | { | 240 | { |
241 | this.SendFullUpdateToAllClients(); | 241 | this.SendFullUpdateToAllClients(); |
242 | this.updateFlag = 0; | 242 | this.updateFlag = 0; |
243 | } | 243 | } |
244 | if (this.updateFlag == 2) //some change has been made so update the clients | 244 | if (this.updateFlag == 2) //some change has been made so update the clients |
245 | { | 245 | { |
246 | this.SendTerseUpdateToALLClients(); | 246 | this.SendTerseUpdateToALLClients(); |
247 | this.updateFlag = 0; | 247 | this.updateFlag = 0; |
248 | } | 248 | } |
249 | 249 | ||
250 | foreach (EntityBase child in children) | 250 | foreach (EntityBase child in children) |
251 | { | 251 | { |
252 | child.update(); | 252 | child.update(); |
253 | } | 253 | } |
254 | } | 254 | } |
255 | #endregion | 255 | #endregion |
256 | 256 | ||
257 | #region Setup | 257 | #region Setup |
258 | /// <summary> | 258 | /// <summary> |
259 | /// | 259 | /// |
260 | /// </summary> | 260 | /// </summary> |
261 | /// <param name="addPacket"></param> | 261 | /// <param name="addPacket"></param> |
262 | /// <param name="ownerID"></param> | 262 | /// <param name="ownerID"></param> |
263 | /// <param name="localID"></param> | 263 | /// <param name="localID"></param> |
264 | public void CreateFromShape(LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) | 264 | public void CreateFromShape(LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) |
265 | { | 265 | { |
266 | this.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | 266 | this.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; |
267 | this.OwnerID = ownerID; | 267 | this.OwnerID = ownerID; |
268 | this.CreatorID = this.OwnerID; | 268 | this.CreatorID = this.OwnerID; |
269 | this.LastOwnerID = LLUUID.Zero; | 269 | this.LastOwnerID = LLUUID.Zero; |
270 | this.Pos = pos; | 270 | this.Pos = pos; |
271 | this.uuid = LLUUID.Random(); | 271 | this.uuid = LLUUID.Random(); |
272 | this.m_localId = (uint)(localID); | 272 | this.m_localId = (uint)(localID); |
273 | 273 | ||
274 | this.m_Shape = shape; | 274 | this.m_Shape = shape; |
275 | this.updateFlag = 1; | 275 | this.updateFlag = 1; |
276 | } | 276 | } |
277 | 277 | ||
278 | #endregion | 278 | #endregion |
279 | 279 | ||
280 | #region Linking / unlinking | 280 | #region Linking / unlinking |
281 | /// <summary> | 281 | /// <summary> |
282 | /// | 282 | /// |
283 | /// </summary> | 283 | /// </summary> |
284 | /// <param name="linkObject"></param> | 284 | /// <param name="linkObject"></param> |
285 | public void AddNewChildren(SceneObject linkObject) | 285 | public void AddNewChildren(SceneObject linkObject) |
286 | { | 286 | { |
287 | // Console.WriteLine("linking new prims " + linkObject.rootLocalID + " to me (" + this.LocalId + ")"); | 287 | // Console.WriteLine("linking new prims " + linkObject.rootLocalID + " to me (" + this.LocalId + ")"); |
288 | //TODO check permissions | 288 | //TODO check permissions |
289 | this.children.Add(linkObject.rootPrimitive); | 289 | this.children.Add(linkObject.rootPrimitive); |
290 | linkObject.rootPrimitive.SetNewParent(this, this.m_RootParent); | 290 | linkObject.rootPrimitive.SetNewParent(this, this.m_RootParent); |
291 | 291 | ||
292 | this.m_world.DeleteEntity(linkObject.rootUUID); | 292 | this.m_world.DeleteEntity(linkObject.rootUUID); |
293 | linkObject.DeleteAllChildren(); | 293 | linkObject.DeleteAllChildren(); |
294 | 294 | ||
295 | this.OnPrimCountTainted(); | 295 | this.OnPrimCountTainted(); |
296 | } | 296 | } |
297 | 297 | ||
298 | /// <summary> | 298 | /// <summary> |
299 | /// | 299 | /// |
300 | /// </summary> | 300 | /// </summary> |
301 | /// <param name="newParent"></param> | 301 | /// <param name="newParent"></param> |
302 | /// <param name="rootParent"></param> | 302 | /// <param name="rootParent"></param> |
303 | public void SetNewParent(Primitive newParent, SceneObject rootParent) | 303 | public void SetNewParent(Primitive newParent, SceneObject rootParent) |
304 | { | 304 | { |
305 | LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z); | 305 | LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z); |
306 | this.m_isRootPrim = false; | 306 | this.m_isRootPrim = false; |
307 | this.m_Parent = newParent; | 307 | this.m_Parent = newParent; |
308 | this.ParentID = newParent.LocalId; | 308 | this.ParentID = newParent.LocalId; |
309 | this.m_RootParent = rootParent; | 309 | this.m_RootParent = rootParent; |
310 | this.m_RootParent.AddChildToList(this); | 310 | this.m_RootParent.AddChildToList(this); |
311 | this.Pos = oldPos; | 311 | this.Pos = oldPos; |
312 | Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z); | 312 | Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z); |
313 | axPos = this.m_Parent.Rotation.Inverse() * axPos; | 313 | axPos = this.m_Parent.Rotation.Inverse() * axPos; |
314 | this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); | 314 | this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); |
315 | Axiom.Math.Quaternion oldRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z); | 315 | Axiom.Math.Quaternion oldRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z); |
316 | this.Rotation = this.m_Parent.Rotation.Inverse() * this.Rotation; | 316 | this.Rotation = this.m_Parent.Rotation.Inverse() * this.Rotation; |
317 | this.updateFlag = 1; | 317 | this.updateFlag = 1; |
318 | 318 | ||
319 | foreach (Primitive child in children) | 319 | foreach (Primitive child in children) |
320 | { | 320 | { |
321 | child.SetRootParent(rootParent, newParent, oldPos, oldRot); | 321 | child.SetRootParent(rootParent, newParent, oldPos, oldRot); |
322 | } | 322 | } |
323 | children.Clear(); | 323 | children.Clear(); |
324 | 324 | ||
325 | 325 | ||
326 | } | 326 | } |
327 | 327 | ||
328 | /// <summary> | 328 | /// <summary> |
329 | /// | 329 | /// |
330 | /// </summary> | 330 | /// </summary> |
331 | /// <param name="newRoot"></param> | 331 | /// <param name="newRoot"></param> |
332 | public void SetRootParent(SceneObject newRoot , Primitive newParent, LLVector3 oldParentPosition, Axiom.Math.Quaternion oldParentRotation) | 332 | public void SetRootParent(SceneObject newRoot , Primitive newParent, LLVector3 oldParentPosition, Axiom.Math.Quaternion oldParentRotation) |
333 | { | 333 | { |
334 | LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z); | 334 | LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z); |
335 | Axiom.Math.Vector3 axOldPos = new Vector3(oldPos.X, oldPos.Y, oldPos.Z); | 335 | Axiom.Math.Vector3 axOldPos = new Vector3(oldPos.X, oldPos.Y, oldPos.Z); |
336 | axOldPos = oldParentRotation * axOldPos; | 336 | axOldPos = oldParentRotation * axOldPos; |
337 | oldPos = new LLVector3(axOldPos.x, axOldPos.y, axOldPos.z); | 337 | oldPos = new LLVector3(axOldPos.x, axOldPos.y, axOldPos.z); |
338 | oldPos += oldParentPosition; | 338 | oldPos += oldParentPosition; |
339 | Axiom.Math.Quaternion oldRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z); | 339 | Axiom.Math.Quaternion oldRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z); |
340 | this.m_isRootPrim = false; | 340 | this.m_isRootPrim = false; |
341 | this.m_Parent = newParent; | 341 | this.m_Parent = newParent; |
342 | this.ParentID = newParent.LocalId; | 342 | this.ParentID = newParent.LocalId; |
343 | newParent.AddToChildrenList(this); | 343 | newParent.AddToChildrenList(this); |
344 | this.m_RootParent = newRoot; | 344 | this.m_RootParent = newRoot; |
345 | this.m_RootParent.AddChildToList(this); | 345 | this.m_RootParent.AddChildToList(this); |
346 | this.Pos = oldPos; | 346 | this.Pos = oldPos; |
347 | Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z); | 347 | Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z); |
348 | axPos = this.m_Parent.Rotation.Inverse() * axPos; | 348 | axPos = this.m_Parent.Rotation.Inverse() * axPos; |
349 | this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); | 349 | this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); |
350 | this.Rotation = oldParentRotation * this.Rotation; | 350 | this.Rotation = oldParentRotation * this.Rotation; |
351 | this.Rotation = this.m_Parent.Rotation.Inverse()* this.Rotation ; | 351 | this.Rotation = this.m_Parent.Rotation.Inverse()* this.Rotation ; |
352 | this.updateFlag = 1; | 352 | this.updateFlag = 1; |
353 | foreach (Primitive child in children) | 353 | foreach (Primitive child in children) |
354 | { | 354 | { |
355 | child.SetRootParent(newRoot, newParent, oldPos, oldRot); | 355 | child.SetRootParent(newRoot, newParent, oldPos, oldRot); |
356 | } | 356 | } |
357 | children.Clear(); | 357 | children.Clear(); |
358 | } | 358 | } |
359 | 359 | ||
360 | /// <summary> | 360 | /// <summary> |
361 | /// | 361 | /// |
362 | /// </summary> | 362 | /// </summary> |
363 | /// <param name="offset"></param> | 363 | /// <param name="offset"></param> |
364 | public void AddOffsetToChildren(LLVector3 offset) | 364 | public void AddOffsetToChildren(LLVector3 offset) |
365 | { | 365 | { |
366 | foreach (Primitive prim in this.children) | 366 | foreach (Primitive prim in this.children) |
367 | { | 367 | { |
368 | prim.m_pos += offset; | 368 | prim.m_pos += offset; |
369 | prim.updateFlag = 2; | 369 | prim.updateFlag = 2; |
370 | } | 370 | } |
371 | this.OnPrimCountTainted(); | 371 | this.OnPrimCountTainted(); |
372 | } | 372 | } |
373 | 373 | ||
374 | /// <summary> | 374 | /// <summary> |
375 | /// | 375 | /// |
376 | /// </summary> | 376 | /// </summary> |
377 | /// <param name="prim"></param> | 377 | /// <param name="prim"></param> |
378 | public void AddToChildrenList(Primitive prim) | 378 | public void AddToChildrenList(Primitive prim) |
379 | { | 379 | { |
380 | this.children.Add(prim); | 380 | this.children.Add(prim); |
381 | } | 381 | } |
382 | #endregion | 382 | #endregion |
383 | 383 | ||
384 | #region Resizing/Scale | 384 | #region Resizing/Scale |
385 | /// <summary> | 385 | /// <summary> |
386 | /// | 386 | /// |
387 | /// </summary> | 387 | /// </summary> |
388 | /// <param name="scale"></param> | 388 | /// <param name="scale"></param> |
389 | public void ResizeGoup(LLVector3 scale) | 389 | public void ResizeGoup(LLVector3 scale) |
390 | { | 390 | { |
391 | LLVector3 offset = (scale - this.m_Shape.Scale); | 391 | LLVector3 offset = (scale - this.m_Shape.Scale); |
392 | offset.X /= 2; | 392 | offset.X /= 2; |
393 | offset.Y /= 2; | 393 | offset.Y /= 2; |
394 | offset.Z /= 2; | 394 | offset.Z /= 2; |
395 | if (this.m_isRootPrim) | 395 | if (this.m_isRootPrim) |
396 | { | 396 | { |
397 | this.m_Parent.Pos += offset; | 397 | this.m_Parent.Pos += offset; |
398 | } | 398 | } |
399 | else | 399 | else |
400 | { | 400 | { |
401 | this.m_pos += offset; | 401 | this.m_pos += offset; |
402 | } | 402 | } |
403 | 403 | ||
404 | this.AddOffsetToChildren(new LLVector3(-offset.X, -offset.Y, -offset.Z)); | 404 | this.AddOffsetToChildren(new LLVector3(-offset.X, -offset.Y, -offset.Z)); |
405 | this.m_Shape.Scale = scale; | 405 | this.m_Shape.Scale = scale; |
406 | 406 | ||
407 | this.updateFlag = 1; | 407 | this.updateFlag = 1; |
408 | } | 408 | } |
409 | #endregion | 409 | #endregion |
410 | 410 | ||
411 | #region Position | 411 | #region Position |
412 | /// <summary> | 412 | /// <summary> |
413 | /// | 413 | /// |
414 | /// </summary> | 414 | /// </summary> |
415 | /// <param name="pos"></param> | 415 | /// <param name="pos"></param> |
416 | public void UpdateGroupPosition(LLVector3 pos) | 416 | public void UpdateGroupPosition(LLVector3 pos) |
417 | { | 417 | { |
418 | LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); | 418 | LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); |
419 | 419 | ||
420 | this.Pos = newPos; | 420 | this.Pos = newPos; |
421 | this.updateFlag = 2; | 421 | this.updateFlag = 2; |
422 | 422 | ||
423 | this.OnPrimCountTainted(); | 423 | this.OnPrimCountTainted(); |
424 | } | 424 | } |
425 | 425 | ||
426 | /// <summary> | 426 | /// <summary> |
427 | /// | 427 | /// |
428 | /// </summary> | 428 | /// </summary> |
429 | /// <param name="pos"></param> | 429 | /// <param name="pos"></param> |
430 | public void UpdateSinglePosition(LLVector3 pos) | 430 | public void UpdateSinglePosition(LLVector3 pos) |
431 | { | 431 | { |
432 | // Console.WriteLine("updating single prim position"); | 432 | // Console.WriteLine("updating single prim position"); |
433 | if (this.m_isRootPrim) | 433 | if (this.m_isRootPrim) |
434 | { | 434 | { |
435 | LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); | 435 | LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); |
436 | LLVector3 oldPos = new LLVector3(Pos.X, Pos.Y, Pos.Z); | 436 | LLVector3 oldPos = new LLVector3(Pos.X, Pos.Y, Pos.Z); |
437 | LLVector3 diff = oldPos - newPos; | 437 | LLVector3 diff = oldPos - newPos; |
438 | Axiom.Math.Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z); | 438 | Axiom.Math.Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z); |
439 | axDiff = this.Rotation.Inverse() * axDiff; | 439 | axDiff = this.Rotation.Inverse() * axDiff; |
440 | diff.X = axDiff.x; | 440 | diff.X = axDiff.x; |
441 | diff.Y = axDiff.y; | 441 | diff.Y = axDiff.y; |
442 | diff.Z = axDiff.z; | 442 | diff.Z = axDiff.z; |
443 | this.Pos = newPos; | 443 | this.Pos = newPos; |
444 | 444 | ||
445 | foreach (Primitive prim in this.children) | 445 | foreach (Primitive prim in this.children) |
446 | { | 446 | { |
447 | prim.m_pos += diff; | 447 | prim.m_pos += diff; |
448 | prim.updateFlag = 2; | 448 | prim.updateFlag = 2; |
449 | } | 449 | } |
450 | this.updateFlag = 2; | 450 | this.updateFlag = 2; |
451 | } | 451 | } |
452 | else | 452 | else |
453 | { | 453 | { |
454 | LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); | 454 | LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); |
455 | this.m_pos = newPos; | 455 | this.m_pos = newPos; |
456 | this.updateFlag = 2; | 456 | this.updateFlag = 2; |
457 | } | 457 | } |
458 | 458 | ||
459 | 459 | ||
460 | } | 460 | } |
461 | 461 | ||
462 | #endregion | 462 | #endregion |
463 | 463 | ||
464 | #region Rotation | 464 | #region Rotation |
465 | /// <summary> | 465 | /// <summary> |
466 | /// | 466 | /// |
467 | /// </summary> | 467 | /// </summary> |
468 | /// <param name="rot"></param> | 468 | /// <param name="rot"></param> |
469 | public void UpdateGroupRotation(LLQuaternion rot) | 469 | public void UpdateGroupRotation(LLQuaternion rot) |
470 | { | 470 | { |
471 | this.Rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z); | 471 | this.Rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z); |
472 | this.updateFlag = 2; | 472 | this.updateFlag = 2; |
473 | 473 | ||
474 | } | 474 | } |
475 | 475 | ||
476 | /// <summary> | 476 | /// <summary> |
477 | /// | 477 | /// |
478 | /// </summary> | 478 | /// </summary> |
479 | /// <param name="pos"></param> | 479 | /// <param name="pos"></param> |
480 | /// <param name="rot"></param> | 480 | /// <param name="rot"></param> |
481 | public void UpdateGroupMouseRotation(LLVector3 pos, LLQuaternion rot) | 481 | public void UpdateGroupMouseRotation(LLVector3 pos, LLQuaternion rot) |
482 | { | 482 | { |
483 | this.Rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z); | 483 | this.Rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z); |
484 | this.Pos = pos; | 484 | this.Pos = pos; |
485 | this.updateFlag = 2; | 485 | this.updateFlag = 2; |
486 | } | 486 | } |
487 | 487 | ||
488 | /// <summary> | 488 | /// <summary> |
489 | /// | 489 | /// |
490 | /// </summary> | 490 | /// </summary> |
491 | /// <param name="rot"></param> | 491 | /// <param name="rot"></param> |
492 | public void UpdateSingleRotation(LLQuaternion rot) | 492 | public void UpdateSingleRotation(LLQuaternion rot) |
493 | { | 493 | { |
494 | //Console.WriteLine("updating single prim rotation"); | 494 | //Console.WriteLine("updating single prim rotation"); |
495 | Axiom.Math.Quaternion axRot = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z); | 495 | Axiom.Math.Quaternion axRot = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z); |
496 | Axiom.Math.Quaternion oldParentRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z); | 496 | Axiom.Math.Quaternion oldParentRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z); |
497 | this.Rotation = axRot; | 497 | this.Rotation = axRot; |
498 | foreach (Primitive prim in this.children) | 498 | foreach (Primitive prim in this.children) |
499 | { | 499 | { |
500 | Axiom.Math.Vector3 axPos = new Vector3(prim.m_pos.X, prim.m_pos.Y, prim.m_pos.Z); | 500 | Axiom.Math.Vector3 axPos = new Vector3(prim.m_pos.X, prim.m_pos.Y, prim.m_pos.Z); |
501 | axPos = oldParentRot * axPos; | 501 | axPos = oldParentRot * axPos; |
502 | axPos = axRot.Inverse() * axPos; | 502 | axPos = axRot.Inverse() * axPos; |
503 | prim.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); | 503 | prim.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); |
504 | prim.Rotation = oldParentRot * prim.Rotation ; | 504 | prim.Rotation = oldParentRot * prim.Rotation ; |
505 | prim.Rotation = axRot.Inverse()* prim.Rotation; | 505 | prim.Rotation = axRot.Inverse()* prim.Rotation; |
506 | prim.updateFlag = 2; | 506 | prim.updateFlag = 2; |
507 | } | 507 | } |
508 | this.updateFlag = 2; | 508 | this.updateFlag = 2; |
509 | } | 509 | } |
510 | #endregion | 510 | #endregion |
511 | 511 | ||
512 | #region Shape | 512 | #region Shape |
513 | /// <summary> | 513 | /// <summary> |
514 | /// | 514 | /// |
515 | /// </summary> | 515 | /// </summary> |
516 | /// <param name="shapeBlock"></param> | 516 | /// <param name="shapeBlock"></param> |
517 | public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock) | 517 | public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock) |
518 | { | 518 | { |
519 | this.m_Shape.PathBegin = shapeBlock.PathBegin; | 519 | this.m_Shape.PathBegin = shapeBlock.PathBegin; |
520 | this.m_Shape.PathEnd = shapeBlock.PathEnd; | 520 | this.m_Shape.PathEnd = shapeBlock.PathEnd; |
521 | this.m_Shape.PathScaleX = shapeBlock.PathScaleX; | 521 | this.m_Shape.PathScaleX = shapeBlock.PathScaleX; |
522 | this.m_Shape.PathScaleY = shapeBlock.PathScaleY; | 522 | this.m_Shape.PathScaleY = shapeBlock.PathScaleY; |
523 | this.m_Shape.PathShearX = shapeBlock.PathShearX; | 523 | this.m_Shape.PathShearX = shapeBlock.PathShearX; |
524 | this.m_Shape.PathShearY = shapeBlock.PathShearY; | 524 | this.m_Shape.PathShearY = shapeBlock.PathShearY; |
525 | this.m_Shape.PathSkew = shapeBlock.PathSkew; | 525 | this.m_Shape.PathSkew = shapeBlock.PathSkew; |
526 | this.m_Shape.ProfileBegin = shapeBlock.ProfileBegin; | 526 | this.m_Shape.ProfileBegin = shapeBlock.ProfileBegin; |
527 | this.m_Shape.ProfileEnd = shapeBlock.ProfileEnd; | 527 | this.m_Shape.ProfileEnd = shapeBlock.ProfileEnd; |
528 | this.m_Shape.PathCurve = shapeBlock.PathCurve; | 528 | this.m_Shape.PathCurve = shapeBlock.PathCurve; |
529 | this.m_Shape.ProfileCurve = shapeBlock.ProfileCurve; | 529 | this.m_Shape.ProfileCurve = shapeBlock.ProfileCurve; |
530 | this.m_Shape.ProfileHollow = shapeBlock.ProfileHollow; | 530 | this.m_Shape.ProfileHollow = shapeBlock.ProfileHollow; |
531 | this.m_Shape.PathRadiusOffset = shapeBlock.PathRadiusOffset; | 531 | this.m_Shape.PathRadiusOffset = shapeBlock.PathRadiusOffset; |
532 | this.m_Shape.PathRevolutions = shapeBlock.PathRevolutions; | 532 | this.m_Shape.PathRevolutions = shapeBlock.PathRevolutions; |
533 | this.m_Shape.PathTaperX = shapeBlock.PathTaperX; | 533 | this.m_Shape.PathTaperX = shapeBlock.PathTaperX; |
534 | this.m_Shape.PathTaperY = shapeBlock.PathTaperY; | 534 | this.m_Shape.PathTaperY = shapeBlock.PathTaperY; |
535 | this.m_Shape.PathTwist = shapeBlock.PathTwist; | 535 | this.m_Shape.PathTwist = shapeBlock.PathTwist; |
536 | this.m_Shape.PathTwistBegin = shapeBlock.PathTwistBegin; | 536 | this.m_Shape.PathTwistBegin = shapeBlock.PathTwistBegin; |
537 | this.updateFlag = 1; | 537 | this.updateFlag = 1; |
538 | } | 538 | } |
539 | #endregion | 539 | #endregion |
540 | 540 | ||
541 | #region Texture | 541 | #region Texture |
542 | /// <summary> | 542 | /// <summary> |
543 | /// | 543 | /// |
544 | /// </summary> | 544 | /// </summary> |
545 | /// <param name="textureEntry"></param> | 545 | /// <param name="textureEntry"></param> |
546 | public void UpdateTextureEntry(byte[] textureEntry) | 546 | public void UpdateTextureEntry(byte[] textureEntry) |
547 | { | 547 | { |
548 | this.m_Shape.TextureEntry = textureEntry; | 548 | this.m_Shape.TextureEntry = textureEntry; |
549 | this.updateFlag = 1; | 549 | this.updateFlag = 1; |
550 | } | 550 | } |
551 | #endregion | 551 | #endregion |
552 | 552 | ||
553 | #region Client Update Methods | 553 | #region Client Update Methods |
554 | 554 | ||
555 | /// <summary> | 555 | /// <summary> |
556 | /// | 556 | /// |
557 | /// </summary> | 557 | /// </summary> |
558 | /// <param name="remoteClient"></param> | 558 | /// <param name="remoteClient"></param> |
559 | public void SendFullUpdateForAllChildren(IClientAPI remoteClient) | 559 | public void SendFullUpdateForAllChildren(IClientAPI remoteClient) |
560 | { | 560 | { |
561 | this.SendFullUpdateToClient(remoteClient); | 561 | this.SendFullUpdateToClient(remoteClient); |
562 | for (int i = 0; i < this.children.Count; i++) | 562 | for (int i = 0; i < this.children.Count; i++) |
563 | { | 563 | { |
564 | if (this.children[i] is Primitive) | 564 | if (this.children[i] is Primitive) |
565 | { | 565 | { |
566 | ((Primitive)this.children[i]).SendFullUpdateForAllChildren(remoteClient); | 566 | ((Primitive)this.children[i]).SendFullUpdateForAllChildren(remoteClient); |
567 | } | 567 | } |
568 | } | 568 | } |
569 | } | 569 | } |
570 | 570 | ||
571 | /// <summary> | 571 | /// <summary> |
572 | /// | 572 | /// |
573 | /// </summary> | 573 | /// </summary> |
574 | /// <param name="remoteClient"></param> | 574 | /// <param name="remoteClient"></param> |
575 | public void SendFullUpdateToClient(IClientAPI remoteClient) | 575 | public void SendFullUpdateToClient(IClientAPI remoteClient) |
576 | { | 576 | { |
577 | LLVector3 lPos; | 577 | LLVector3 lPos; |
578 | lPos = this.Pos; | 578 | lPos = this.Pos; |
579 | LLQuaternion lRot; | 579 | LLQuaternion lRot; |
580 | lRot = new LLQuaternion(this.Rotation.x, this.Rotation.y, this.Rotation.z, this.Rotation.w); | 580 | lRot = new LLQuaternion(this.Rotation.x, this.Rotation.y, this.Rotation.z, this.Rotation.w); |
581 | 581 | ||
582 | remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.m_Shape, lPos, lRot, this.m_flags, this.uuid, this.OwnerID, this.Text, this.ParentID); | 582 | remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.m_Shape, lPos, lRot, this.m_flags, this.uuid, this.OwnerID, this.Text, this.ParentID); |
583 | } | 583 | } |
584 | 584 | ||
585 | /// <summary> | 585 | /// <summary> |
586 | /// | 586 | /// |
587 | /// </summary> | 587 | /// </summary> |
588 | public void SendFullUpdateToAllClients() | 588 | public void SendFullUpdateToAllClients() |
589 | { | 589 | { |
590 | List<ScenePresence> avatars = this.m_world.RequestAvatarList(); | 590 | List<ScenePresence> avatars = this.m_world.RequestAvatarList(); |
591 | for (int i = 0; i < avatars.Count; i++) | 591 | for (int i = 0; i < avatars.Count; i++) |
592 | { | 592 | { |
593 | this.SendFullUpdateToClient(avatars[i].ControllingClient); | 593 | this.SendFullUpdateToClient(avatars[i].ControllingClient); |
594 | } | 594 | } |
595 | } | 595 | } |
596 | 596 | ||
597 | /// <summary> | 597 | /// <summary> |
598 | /// | 598 | /// |
599 | /// </summary> | 599 | /// </summary> |
600 | /// <param name="remoteClient"></param> | 600 | /// <param name="remoteClient"></param> |
601 | public void SendTerseUpdateForAllChildren(IClientAPI remoteClient) | 601 | public void SendTerseUpdateForAllChildren(IClientAPI remoteClient) |
602 | { | 602 | { |
603 | this.SendTerseUpdateToClient(remoteClient); | 603 | this.SendTerseUpdateToClient(remoteClient); |
604 | for (int i = 0; i < this.children.Count; i++) | 604 | for (int i = 0; i < this.children.Count; i++) |
605 | { | 605 | { |
606 | if (this.children[i] is Primitive) | 606 | if (this.children[i] is Primitive) |
607 | { | 607 | { |
608 | ((Primitive)this.children[i]).SendTerseUpdateForAllChildren(remoteClient); | 608 | ((Primitive)this.children[i]).SendTerseUpdateForAllChildren(remoteClient); |
609 | } | 609 | } |
610 | } | 610 | } |
611 | } | 611 | } |
612 | 612 | ||
613 | /// <summary> | 613 | /// <summary> |
614 | /// | 614 | /// |
615 | /// </summary> | 615 | /// </summary> |
616 | /// <param name="RemoteClient"></param> | 616 | /// <param name="RemoteClient"></param> |
617 | public void SendTerseUpdateToClient(IClientAPI RemoteClient) | 617 | public void SendTerseUpdateToClient(IClientAPI RemoteClient) |
618 | { | 618 | { |
619 | LLVector3 lPos; | 619 | LLVector3 lPos; |
620 | Quaternion lRot; | 620 | Quaternion lRot; |
621 | 621 | ||
622 | lPos = this.Pos; | 622 | lPos = this.Pos; |
623 | lRot = this.Rotation; | 623 | lRot = this.Rotation; |
624 | 624 | ||
625 | LLQuaternion mRot = new LLQuaternion(lRot.x, lRot.y, lRot.z, lRot.w); | 625 | LLQuaternion mRot = new LLQuaternion(lRot.x, lRot.y, lRot.z, lRot.w); |
626 | RemoteClient.SendPrimTerseUpdate(this.m_regionHandle, 64096, this.LocalId, lPos, mRot); | 626 | RemoteClient.SendPrimTerseUpdate(this.m_regionHandle, 64096, this.LocalId, lPos, mRot); |
627 | } | 627 | } |
628 | 628 | ||
629 | /// <summary> | 629 | /// <summary> |
630 | /// | 630 | /// |
631 | /// </summary> | 631 | /// </summary> |
632 | public void SendTerseUpdateToALLClients() | 632 | public void SendTerseUpdateToALLClients() |
633 | { | 633 | { |
634 | List<ScenePresence> avatars = this.m_world.RequestAvatarList(); | 634 | List<ScenePresence> avatars = this.m_world.RequestAvatarList(); |
635 | for (int i = 0; i < avatars.Count; i++) | 635 | for (int i = 0; i < avatars.Count; i++) |
636 | { | 636 | { |
637 | this.SendTerseUpdateToClient(avatars[i].ControllingClient); | 637 | this.SendTerseUpdateToClient(avatars[i].ControllingClient); |
638 | } | 638 | } |
639 | } | 639 | } |
640 | 640 | ||
641 | #endregion | 641 | #endregion |
642 | 642 | ||
643 | public void TriggerOnPrimCountTainted() | 643 | public void TriggerOnPrimCountTainted() |
644 | { | 644 | { |
645 | this.OnPrimCountTainted(); | 645 | this.OnPrimCountTainted(); |
646 | } | 646 | } |
647 | } | 647 | } |
648 | } | 648 | } |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index 347625a..e37d105 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs | |||
@@ -1,618 +1,618 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using libsecondlife; | 30 | using libsecondlife; |
31 | using libsecondlife.Packets; | 31 | using libsecondlife.Packets; |
32 | using OpenSim.Framework.Interfaces; | 32 | using OpenSim.Framework.Interfaces; |
33 | using OpenSim.Framework.Types; | 33 | using OpenSim.Framework.Types; |
34 | 34 | ||
35 | namespace OpenSim.Region.Environment.Scenes | 35 | namespace OpenSim.Region.Environment.Scenes |
36 | { | 36 | { |
37 | public partial class Scene | 37 | public partial class Scene |
38 | { | 38 | { |
39 | /// <summary> | 39 | /// <summary> |
40 | /// Modifies terrain using the specified information | 40 | /// Modifies terrain using the specified information |
41 | /// </summary> | 41 | /// </summary> |
42 | /// <param name="height">The height at which the user started modifying the terrain</param> | 42 | /// <param name="height">The height at which the user started modifying the terrain</param> |
43 | /// <param name="seconds">The number of seconds the modify button was pressed</param> | 43 | /// <param name="seconds">The number of seconds the modify button was pressed</param> |
44 | /// <param name="brushsize">The size of the brush used</param> | 44 | /// <param name="brushsize">The size of the brush used</param> |
45 | /// <param name="action">The action to be performed</param> | 45 | /// <param name="action">The action to be performed</param> |
46 | /// <param name="north">Distance from the north border where the cursor is located</param> | 46 | /// <param name="north">Distance from the north border where the cursor is located</param> |
47 | /// <param name="west">Distance from the west border where the cursor is located</param> | 47 | /// <param name="west">Distance from the west border where the cursor is located</param> |
48 | public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west) | 48 | public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west) |
49 | { | 49 | { |
50 | // Shiny. | 50 | // Shiny. |
51 | double size = (double)(1 << brushsize); | 51 | double size = (double)(1 << brushsize); |
52 | 52 | ||
53 | switch (action) | 53 | switch (action) |
54 | { | 54 | { |
55 | case 0: | 55 | case 0: |
56 | // flatten terrain | 56 | // flatten terrain |
57 | Terrain.flatten(north, west, size, (double)seconds / 100.0); | 57 | Terrain.flatten(north, west, size, (double)seconds / 100.0); |
58 | RegenerateTerrain(true, (int)north, (int)west); | 58 | RegenerateTerrain(true, (int)north, (int)west); |
59 | break; | 59 | break; |
60 | case 1: | 60 | case 1: |
61 | // raise terrain | 61 | // raise terrain |
62 | Terrain.raise(north, west, size, (double)seconds / 100.0); | 62 | Terrain.raise(north, west, size, (double)seconds / 100.0); |
63 | RegenerateTerrain(true, (int)north, (int)west); | 63 | RegenerateTerrain(true, (int)north, (int)west); |
64 | break; | 64 | break; |
65 | case 2: | 65 | case 2: |
66 | //lower terrain | 66 | //lower terrain |
67 | Terrain.lower(north, west, size, (double)seconds / 100.0); | 67 | Terrain.lower(north, west, size, (double)seconds / 100.0); |
68 | RegenerateTerrain(true, (int)north, (int)west); | 68 | RegenerateTerrain(true, (int)north, (int)west); |
69 | break; | 69 | break; |
70 | case 3: | 70 | case 3: |
71 | // smooth terrain | 71 | // smooth terrain |
72 | Terrain.smooth(north, west, size, (double)seconds / 100.0); | 72 | Terrain.smooth(north, west, size, (double)seconds / 100.0); |
73 | RegenerateTerrain(true, (int)north, (int)west); | 73 | RegenerateTerrain(true, (int)north, (int)west); |
74 | break; | 74 | break; |
75 | case 4: | 75 | case 4: |
76 | // noise | 76 | // noise |
77 | Terrain.noise(north, west, size, (double)seconds / 100.0); | 77 | Terrain.noise(north, west, size, (double)seconds / 100.0); |
78 | RegenerateTerrain(true, (int)north, (int)west); | 78 | RegenerateTerrain(true, (int)north, (int)west); |
79 | break; | 79 | break; |
80 | case 5: | 80 | case 5: |
81 | // revert | 81 | // revert |
82 | Terrain.revert(north, west, size, (double)seconds / 100.0); | 82 | Terrain.revert(north, west, size, (double)seconds / 100.0); |
83 | RegenerateTerrain(true, (int)north, (int)west); | 83 | RegenerateTerrain(true, (int)north, (int)west); |
84 | break; | 84 | break; |
85 | 85 | ||
86 | // CLIENT EXTENSIONS GO HERE | 86 | // CLIENT EXTENSIONS GO HERE |
87 | case 128: | 87 | case 128: |
88 | // erode-thermal | 88 | // erode-thermal |
89 | break; | 89 | break; |
90 | case 129: | 90 | case 129: |
91 | // erode-aerobic | 91 | // erode-aerobic |
92 | break; | 92 | break; |
93 | case 130: | 93 | case 130: |
94 | // erode-hydraulic | 94 | // erode-hydraulic |
95 | break; | 95 | break; |
96 | } | 96 | } |
97 | return; | 97 | return; |
98 | } | 98 | } |
99 | 99 | ||
100 | /// <summary> | 100 | /// <summary> |
101 | /// | 101 | /// |
102 | /// </summary> | 102 | /// </summary> |
103 | /// <remarks>Inefficient. TODO: Fixme</remarks> | 103 | /// <remarks>Inefficient. TODO: Fixme</remarks> |
104 | /// <param name="fromAgentID"></param> | 104 | /// <param name="fromAgentID"></param> |
105 | /// <param name="toAgentID"></param> | 105 | /// <param name="toAgentID"></param> |
106 | /// <param name="timestamp"></param> | 106 | /// <param name="timestamp"></param> |
107 | /// <param name="fromAgentName"></param> | 107 | /// <param name="fromAgentName"></param> |
108 | /// <param name="message"></param> | 108 | /// <param name="message"></param> |
109 | public void InstantMessage(LLUUID fromAgentID, LLUUID toAgentID, uint timestamp, string fromAgentName, string message) | 109 | public void InstantMessage(LLUUID fromAgentID, LLUUID toAgentID, uint timestamp, string fromAgentName, string message) |
110 | { | 110 | { |
111 | if (this.Avatars.ContainsKey(toAgentID)) | 111 | if (this.Avatars.ContainsKey(toAgentID)) |
112 | { | 112 | { |
113 | if (this.Avatars.ContainsKey(fromAgentID)) | 113 | if (this.Avatars.ContainsKey(fromAgentID)) |
114 | { | 114 | { |
115 | // Local sim message | 115 | // Local sim message |
116 | ScenePresence fromAvatar = this.Avatars[fromAgentID]; | 116 | ScenePresence fromAvatar = this.Avatars[fromAgentID]; |
117 | ScenePresence toAvatar = this.Avatars[toAgentID]; | 117 | ScenePresence toAvatar = this.Avatars[toAgentID]; |
118 | string fromName = fromAvatar.firstname + " " + fromAvatar.lastname; | 118 | string fromName = fromAvatar.firstname + " " + fromAvatar.lastname; |
119 | toAvatar.ControllingClient.SendInstantMessage(message, toAgentID, fromName); | 119 | toAvatar.ControllingClient.SendInstantMessage(message, toAgentID, fromName); |
120 | } | 120 | } |
121 | else | 121 | else |
122 | { | 122 | { |
123 | // Message came from a user outside the sim, ignore? | 123 | // Message came from a user outside the sim, ignore? |
124 | } | 124 | } |
125 | } | 125 | } |
126 | else | 126 | else |
127 | { | 127 | { |
128 | // Grid message | 128 | // Grid message |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | /// <summary> | 132 | /// <summary> |
133 | /// | 133 | /// |
134 | /// </summary> | 134 | /// </summary> |
135 | /// <param name="message"></param> | 135 | /// <param name="message"></param> |
136 | /// <param name="type"></param> | 136 | /// <param name="type"></param> |
137 | /// <param name="fromPos"></param> | 137 | /// <param name="fromPos"></param> |
138 | /// <param name="fromName"></param> | 138 | /// <param name="fromName"></param> |
139 | /// <param name="fromAgentID"></param> | 139 | /// <param name="fromAgentID"></param> |
140 | public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) | 140 | public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) |
141 | { | 141 | { |
142 | ScenePresence avatar = null; | 142 | ScenePresence avatar = null; |
143 | if (this.Avatars.ContainsKey(fromAgentID)) | 143 | if (this.Avatars.ContainsKey(fromAgentID)) |
144 | { | 144 | { |
145 | avatar = this.Avatars[fromAgentID]; | 145 | avatar = this.Avatars[fromAgentID]; |
146 | fromPos = avatar.Pos; | 146 | fromPos = avatar.Pos; |
147 | fromName = avatar.firstname + " " + avatar.lastname; | 147 | fromName = avatar.firstname + " " + avatar.lastname; |
148 | avatar = null; | 148 | avatar = null; |
149 | } | 149 | } |
150 | 150 | ||
151 | this.ForEachScenePresence(delegate(ScenePresence presence) | 151 | this.ForEachScenePresence(delegate(ScenePresence presence) |
152 | { | 152 | { |
153 | int dis = -1000; | 153 | int dis = -1000; |
154 | if (this.Avatars.ContainsKey(presence.ControllingClient.AgentId)) | 154 | if (this.Avatars.ContainsKey(presence.ControllingClient.AgentId)) |
155 | { | 155 | { |
156 | avatar = this.Avatars[presence.ControllingClient.AgentId]; | 156 | avatar = this.Avatars[presence.ControllingClient.AgentId]; |
157 | dis = (int)avatar.Pos.GetDistanceTo(fromPos); | 157 | dis = (int)avatar.Pos.GetDistanceTo(fromPos); |
158 | } | 158 | } |
159 | 159 | ||
160 | switch (type) | 160 | switch (type) |
161 | { | 161 | { |
162 | case 0: // Whisper | 162 | case 0: // Whisper |
163 | if ((dis < 10) && (dis > -10)) | 163 | if ((dis < 10) && (dis > -10)) |
164 | { | 164 | { |
165 | //should change so the message is sent through the avatar rather than direct to the ClientView | 165 | //should change so the message is sent through the avatar rather than direct to the ClientView |
166 | presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, | 166 | presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, |
167 | fromAgentID); | 167 | fromAgentID); |
168 | } | 168 | } |
169 | break; | 169 | break; |
170 | case 1: // Say | 170 | case 1: // Say |
171 | if ((dis < 30) && (dis > -30)) | 171 | if ((dis < 30) && (dis > -30)) |
172 | { | 172 | { |
173 | //Console.WriteLine("sending chat"); | 173 | //Console.WriteLine("sending chat"); |
174 | presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, | 174 | presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, |
175 | fromAgentID); | 175 | fromAgentID); |
176 | } | 176 | } |
177 | break; | 177 | break; |
178 | case 2: // Shout | 178 | case 2: // Shout |
179 | if ((dis < 100) && (dis > -100)) | 179 | if ((dis < 100) && (dis > -100)) |
180 | { | 180 | { |
181 | presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, | 181 | presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, |
182 | fromAgentID); | 182 | fromAgentID); |
183 | } | 183 | } |
184 | break; | 184 | break; |
185 | 185 | ||
186 | case 0xff: // Broadcast | 186 | case 0xff: // Broadcast |
187 | presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, | 187 | presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, |
188 | fromAgentID); | 188 | fromAgentID); |
189 | break; | 189 | break; |
190 | } | 190 | } |
191 | }); | 191 | }); |
192 | } | 192 | } |
193 | 193 | ||
194 | /// <summary> | 194 | /// <summary> |
195 | /// | 195 | /// |
196 | /// </summary> | 196 | /// </summary> |
197 | /// <param name="primAsset"></param> | 197 | /// <param name="primAsset"></param> |
198 | /// <param name="pos"></param> | 198 | /// <param name="pos"></param> |
199 | public void RezObject(AssetBase primAsset, LLVector3 pos) | 199 | public void RezObject(AssetBase primAsset, LLVector3 pos) |
200 | { | 200 | { |
201 | 201 | ||
202 | } | 202 | } |
203 | 203 | ||
204 | /// <summary> | 204 | /// <summary> |
205 | /// | 205 | /// |
206 | /// </summary> | 206 | /// </summary> |
207 | /// <param name="packet"></param> | 207 | /// <param name="packet"></param> |
208 | /// <param name="simClient"></param> | 208 | /// <param name="simClient"></param> |
209 | public void DeRezObject(Packet packet, IClientAPI simClient) | 209 | public void DeRezObject(Packet packet, IClientAPI simClient) |
210 | { | 210 | { |
211 | 211 | ||
212 | } | 212 | } |
213 | 213 | ||
214 | /// <summary> | 214 | /// <summary> |
215 | /// | 215 | /// |
216 | /// </summary> | 216 | /// </summary> |
217 | /// <param name="remoteClient"></param> | 217 | /// <param name="remoteClient"></param> |
218 | public void SendAvatarsToClient(IClientAPI remoteClient) | 218 | public void SendAvatarsToClient(IClientAPI remoteClient) |
219 | { | 219 | { |
220 | 220 | ||
221 | } | 221 | } |
222 | 222 | ||
223 | /// <summary> | 223 | /// <summary> |
224 | /// | 224 | /// |
225 | /// </summary> | 225 | /// </summary> |
226 | /// <param name="originalPrim"></param> | 226 | /// <param name="originalPrim"></param> |
227 | /// <param name="offset"></param> | 227 | /// <param name="offset"></param> |
228 | /// <param name="flags"></param> | 228 | /// <param name="flags"></param> |
229 | public void DuplicateObject(uint originalPrim, LLVector3 offset, uint flags) | 229 | public void DuplicateObject(uint originalPrim, LLVector3 offset, uint flags) |
230 | { | 230 | { |
231 | SceneObject originPrim = null; | 231 | SceneObject originPrim = null; |
232 | foreach (EntityBase ent in Entities.Values) | 232 | foreach (EntityBase ent in Entities.Values) |
233 | { | 233 | { |
234 | if (ent is SceneObject) | 234 | if (ent is SceneObject) |
235 | { | 235 | { |
236 | if (((SceneObject)ent).rootLocalID == originalPrim) | 236 | if (((SceneObject)ent).rootLocalID == originalPrim) |
237 | { | 237 | { |
238 | originPrim = (SceneObject)ent; | 238 | originPrim = (SceneObject)ent; |
239 | break; | 239 | break; |
240 | } | 240 | } |
241 | } | 241 | } |
242 | } | 242 | } |
243 | 243 | ||
244 | if (originPrim != null) | 244 | if (originPrim != null) |
245 | { | 245 | { |
246 | SceneObject copy = originPrim.Copy(); | 246 | SceneObject copy = originPrim.Copy(); |
247 | copy.Pos = copy.Pos + offset; | 247 | copy.Pos = copy.Pos + offset; |
248 | this.Entities.Add(copy.rootUUID, copy); | 248 | this.Entities.Add(copy.rootUUID, copy); |
249 | 249 | ||
250 | List<ScenePresence> avatars = this.RequestAvatarList(); | 250 | List<ScenePresence> avatars = this.RequestAvatarList(); |
251 | for (int i = 0; i < avatars.Count; i++) | 251 | for (int i = 0; i < avatars.Count; i++) |
252 | { | 252 | { |
253 | copy.SendAllChildPrimsToClient(avatars[i].ControllingClient); | 253 | copy.SendAllChildPrimsToClient(avatars[i].ControllingClient); |
254 | } | 254 | } |
255 | 255 | ||
256 | } | 256 | } |
257 | else | 257 | else |
258 | { | 258 | { |
259 | OpenSim.Framework.Console.MainLog.Instance.Warn("Attempted to duplicate nonexistant prim"); | 259 | OpenSim.Framework.Console.MainLog.Instance.Warn("Attempted to duplicate nonexistant prim"); |
260 | } | 260 | } |
261 | 261 | ||
262 | } | 262 | } |
263 | 263 | ||
264 | /// <summary> | 264 | /// <summary> |
265 | /// | 265 | /// |
266 | /// </summary> | 266 | /// </summary> |
267 | /// <param name="parentPrim"></param> | 267 | /// <param name="parentPrim"></param> |
268 | /// <param name="childPrims"></param> | 268 | /// <param name="childPrims"></param> |
269 | public void LinkObjects(uint parentPrim, List<uint> childPrims) | 269 | public void LinkObjects(uint parentPrim, List<uint> childPrims) |
270 | { | 270 | { |
271 | SceneObject parenPrim = null; | 271 | SceneObject parenPrim = null; |
272 | foreach (EntityBase ent in Entities.Values) | 272 | foreach (EntityBase ent in Entities.Values) |
273 | { | 273 | { |
274 | if (ent is SceneObject) | 274 | if (ent is SceneObject) |
275 | { | 275 | { |
276 | if (((SceneObject)ent).rootLocalID == parentPrim) | 276 | if (((SceneObject)ent).rootLocalID == parentPrim) |
277 | { | 277 | { |
278 | parenPrim = (SceneObject)ent; | 278 | parenPrim = (SceneObject)ent; |
279 | break; | 279 | break; |
280 | } | 280 | } |
281 | } | 281 | } |
282 | } | 282 | } |
283 | 283 | ||
284 | List<SceneObject> children = new List<SceneObject>(); | 284 | List<SceneObject> children = new List<SceneObject>(); |
285 | if (parenPrim != null) | 285 | if (parenPrim != null) |
286 | { | 286 | { |
287 | for (int i = 0; i < childPrims.Count; i++) | 287 | for (int i = 0; i < childPrims.Count; i++) |
288 | { | 288 | { |
289 | foreach (EntityBase ent in Entities.Values) | 289 | foreach (EntityBase ent in Entities.Values) |
290 | { | 290 | { |
291 | if (ent is SceneObject) | 291 | if (ent is SceneObject) |
292 | { | 292 | { |
293 | if (((SceneObject)ent).rootLocalID == childPrims[i]) | 293 | if (((SceneObject)ent).rootLocalID == childPrims[i]) |
294 | { | 294 | { |
295 | children.Add((SceneObject)ent); | 295 | children.Add((SceneObject)ent); |
296 | } | 296 | } |
297 | } | 297 | } |
298 | } | 298 | } |
299 | } | 299 | } |
300 | } | 300 | } |
301 | 301 | ||
302 | foreach (SceneObject sceneObj in children) | 302 | foreach (SceneObject sceneObj in children) |
303 | { | 303 | { |
304 | parenPrim.AddNewChildPrims(sceneObj); | 304 | parenPrim.AddNewChildPrims(sceneObj); |
305 | } | 305 | } |
306 | } | 306 | } |
307 | 307 | ||
308 | /// <summary> | 308 | /// <summary> |
309 | /// | 309 | /// |
310 | /// </summary> | 310 | /// </summary> |
311 | /// <param name="primLocalID"></param> | 311 | /// <param name="primLocalID"></param> |
312 | /// <param name="shapeBlock"></param> | 312 | /// <param name="shapeBlock"></param> |
313 | public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock) | 313 | public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock) |
314 | { | 314 | { |
315 | Primitive prim = null; | 315 | Primitive prim = null; |
316 | foreach (EntityBase ent in Entities.Values) | 316 | foreach (EntityBase ent in Entities.Values) |
317 | { | 317 | { |
318 | if (ent is SceneObject) | 318 | if (ent is SceneObject) |
319 | { | 319 | { |
320 | prim = ((SceneObject)ent).HasChildPrim(primLocalID); | 320 | prim = ((SceneObject)ent).HasChildPrim(primLocalID); |
321 | if (prim != null) | 321 | if (prim != null) |
322 | { | 322 | { |
323 | prim.UpdateShape(shapeBlock); | 323 | prim.UpdateShape(shapeBlock); |
324 | break; | 324 | break; |
325 | } | 325 | } |
326 | } | 326 | } |
327 | } | 327 | } |
328 | } | 328 | } |
329 | 329 | ||
330 | /// <summary> | 330 | /// <summary> |
331 | /// | 331 | /// |
332 | /// </summary> | 332 | /// </summary> |
333 | /// <param name="primLocalID"></param> | 333 | /// <param name="primLocalID"></param> |
334 | /// <param name="remoteClient"></param> | 334 | /// <param name="remoteClient"></param> |
335 | public void SelectPrim(uint primLocalID, IClientAPI remoteClient) | 335 | public void SelectPrim(uint primLocalID, IClientAPI remoteClient) |
336 | { | 336 | { |
337 | foreach (EntityBase ent in Entities.Values) | 337 | foreach (EntityBase ent in Entities.Values) |
338 | { | 338 | { |
339 | if (ent is SceneObject) | 339 | if (ent is SceneObject) |
340 | { | 340 | { |
341 | if (((SceneObject)ent).rootLocalID == primLocalID) | 341 | if (((SceneObject)ent).rootLocalID == primLocalID) |
342 | { | 342 | { |
343 | ((SceneObject)ent).GetProperites(remoteClient); | 343 | ((SceneObject)ent).GetProperites(remoteClient); |
344 | ((SceneObject)ent).isSelected = true; | 344 | ((SceneObject)ent).isSelected = true; |
345 | this.ParcelManager.setPrimsTainted(); | 345 | this.ParcelManager.setPrimsTainted(); |
346 | break; | 346 | break; |
347 | } | 347 | } |
348 | } | 348 | } |
349 | } | 349 | } |
350 | } | 350 | } |
351 | 351 | ||
352 | /// <summary> | 352 | /// <summary> |
353 | /// | 353 | /// |
354 | /// </summary> | 354 | /// </summary> |
355 | /// <param name="primLocalID"></param> | 355 | /// <param name="primLocalID"></param> |
356 | /// <param name="remoteClient"></param> | 356 | /// <param name="remoteClient"></param> |
357 | public void DeselectPrim(uint primLocalID, IClientAPI remoteClient) | 357 | public void DeselectPrim(uint primLocalID, IClientAPI remoteClient) |
358 | { | 358 | { |
359 | foreach (EntityBase ent in Entities.Values) | 359 | foreach (EntityBase ent in Entities.Values) |
360 | { | 360 | { |
361 | if (ent is SceneObject) | 361 | if (ent is SceneObject) |
362 | { | 362 | { |
363 | if (((SceneObject)ent).rootLocalID == primLocalID) | 363 | if (((SceneObject)ent).rootLocalID == primLocalID) |
364 | { | 364 | { |
365 | ((SceneObject)ent).isSelected = false; | 365 | ((SceneObject)ent).isSelected = false; |
366 | this.ParcelManager.setPrimsTainted(); | 366 | this.ParcelManager.setPrimsTainted(); |
367 | break; | 367 | break; |
368 | } | 368 | } |
369 | } | 369 | } |
370 | } | 370 | } |
371 | } | 371 | } |
372 | 372 | ||
373 | /// <summary> | 373 | /// <summary> |
374 | /// | 374 | /// |
375 | /// </summary> | 375 | /// </summary> |
376 | /// <param name="primLocalID"></param> | 376 | /// <param name="primLocalID"></param> |
377 | /// <param name="description"></param> | 377 | /// <param name="description"></param> |
378 | public void PrimDescription(uint primLocalID, string description) | 378 | public void PrimDescription(uint primLocalID, string description) |
379 | { | 379 | { |
380 | Primitive prim = null; | 380 | Primitive prim = null; |
381 | foreach (EntityBase ent in Entities.Values) | 381 | foreach (EntityBase ent in Entities.Values) |
382 | { | 382 | { |
383 | if (ent is SceneObject) | 383 | if (ent is SceneObject) |
384 | { | 384 | { |
385 | prim = ((SceneObject)ent).HasChildPrim(primLocalID); | 385 | prim = ((SceneObject)ent).HasChildPrim(primLocalID); |
386 | if (prim != null) | 386 | if (prim != null) |
387 | { | 387 | { |
388 | prim.Description = description; | 388 | prim.Description = description; |
389 | break; | 389 | break; |
390 | } | 390 | } |
391 | } | 391 | } |
392 | } | 392 | } |
393 | } | 393 | } |
394 | 394 | ||
395 | /// <summary> | 395 | /// <summary> |
396 | /// | 396 | /// |
397 | /// </summary> | 397 | /// </summary> |
398 | /// <param name="primLocalID"></param> | 398 | /// <param name="primLocalID"></param> |
399 | /// <param name="description"></param> | 399 | /// <param name="description"></param> |
400 | public void PrimName(uint primLocalID, string name) | 400 | public void PrimName(uint primLocalID, string name) |
401 | { | 401 | { |
402 | Primitive prim = null; | 402 | Primitive prim = null; |
403 | foreach (EntityBase ent in Entities.Values) | 403 | foreach (EntityBase ent in Entities.Values) |
404 | { | 404 | { |
405 | if (ent is SceneObject) | 405 | if (ent is SceneObject) |
406 | { | 406 | { |
407 | prim = ((SceneObject)ent).HasChildPrim(primLocalID); | 407 | prim = ((SceneObject)ent).HasChildPrim(primLocalID); |
408 | if (prim != null) | 408 | if (prim != null) |
409 | { | 409 | { |
410 | prim.Name = name; | 410 | prim.Name = name; |
411 | break; | 411 | break; |
412 | } | 412 | } |
413 | } | 413 | } |
414 | } | 414 | } |
415 | } | 415 | } |
416 | 416 | ||
417 | public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) | 417 | public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) |
418 | { | 418 | { |
419 | Primitive prim = null; | 419 | Primitive prim = null; |
420 | foreach (EntityBase ent in Entities.Values) | 420 | foreach (EntityBase ent in Entities.Values) |
421 | { | 421 | { |
422 | if (ent is SceneObject) | 422 | if (ent is SceneObject) |
423 | { | 423 | { |
424 | prim = ((SceneObject)ent).HasChildPrim(objectID); | 424 | prim = ((SceneObject)ent).HasChildPrim(objectID); |
425 | if (prim != null) | 425 | if (prim != null) |
426 | { | 426 | { |
427 | ((SceneObject)ent).GrapMovement(offset, pos, remoteClient); | 427 | ((SceneObject)ent).GrapMovement(offset, pos, remoteClient); |
428 | break; | 428 | break; |
429 | } | 429 | } |
430 | } | 430 | } |
431 | } | 431 | } |
432 | /* | 432 | /* |
433 | if (this.Entities.ContainsKey(objectID)) | 433 | if (this.Entities.ContainsKey(objectID)) |
434 | { | 434 | { |
435 | if (this.Entities[objectID] is SceneObject) | 435 | if (this.Entities[objectID] is SceneObject) |
436 | { | 436 | { |
437 | ((SceneObject)this.Entities[objectID]).GrapMovement(offset, pos, remoteClient); | 437 | ((SceneObject)this.Entities[objectID]).GrapMovement(offset, pos, remoteClient); |
438 | } | 438 | } |
439 | }*/ | 439 | }*/ |
440 | } | 440 | } |
441 | 441 | ||
442 | /// <summary> | 442 | /// <summary> |
443 | /// | 443 | /// |
444 | /// </summary> | 444 | /// </summary> |
445 | /// <param name="localID"></param> | 445 | /// <param name="localID"></param> |
446 | /// <param name="packet"></param> | 446 | /// <param name="packet"></param> |
447 | /// <param name="remoteClient"></param> | 447 | /// <param name="remoteClient"></param> |
448 | public void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient) | 448 | public void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient) |
449 | { | 449 | { |
450 | 450 | ||
451 | } | 451 | } |
452 | 452 | ||
453 | /// <summary> | 453 | /// <summary> |
454 | /// | 454 | /// |
455 | /// </summary> | 455 | /// </summary> |
456 | /// <param name="localID"></param> | 456 | /// <param name="localID"></param> |
457 | /// <param name="texture"></param> | 457 | /// <param name="texture"></param> |
458 | /// <param name="remoteClient"></param> | 458 | /// <param name="remoteClient"></param> |
459 | public void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient) | 459 | public void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient) |
460 | { | 460 | { |
461 | Primitive prim = null; | 461 | Primitive prim = null; |
462 | foreach (EntityBase ent in Entities.Values) | 462 | foreach (EntityBase ent in Entities.Values) |
463 | { | 463 | { |
464 | if (ent is SceneObject) | 464 | if (ent is SceneObject) |
465 | { | 465 | { |
466 | prim = ((SceneObject)ent).HasChildPrim(localID); | 466 | prim = ((SceneObject)ent).HasChildPrim(localID); |
467 | if (prim != null) | 467 | if (prim != null) |
468 | { | 468 | { |
469 | prim.UpdateTextureEntry(texture); | 469 | prim.UpdateTextureEntry(texture); |
470 | } | 470 | } |
471 | } | 471 | } |
472 | } | 472 | } |
473 | } | 473 | } |
474 | 474 | ||
475 | /// <summary> | 475 | /// <summary> |
476 | /// | 476 | /// |
477 | /// </summary> | 477 | /// </summary> |
478 | /// <param name="localID"></param> | 478 | /// <param name="localID"></param> |
479 | /// <param name="pos"></param> | 479 | /// <param name="pos"></param> |
480 | /// <param name="remoteClient"></param> | 480 | /// <param name="remoteClient"></param> |
481 | public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient) | 481 | public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient) |
482 | { | 482 | { |
483 | Primitive prim = null; | 483 | Primitive prim = null; |
484 | foreach (EntityBase ent in Entities.Values) | 484 | foreach (EntityBase ent in Entities.Values) |
485 | { | 485 | { |
486 | if (ent is SceneObject) | 486 | if (ent is SceneObject) |
487 | { | 487 | { |
488 | prim = ((SceneObject)ent).HasChildPrim(localID); | 488 | prim = ((SceneObject)ent).HasChildPrim(localID); |
489 | if (prim != null) | 489 | if (prim != null) |
490 | { | 490 | { |
491 | prim.UpdateGroupPosition(pos); | 491 | prim.UpdateGroupPosition(pos); |
492 | break; | 492 | break; |
493 | } | 493 | } |
494 | } | 494 | } |
495 | } | 495 | } |
496 | } | 496 | } |
497 | 497 | ||
498 | public void UpdatePrimSinglePosition(uint localID, LLVector3 pos, IClientAPI remoteClient) | 498 | public void UpdatePrimSinglePosition(uint localID, LLVector3 pos, IClientAPI remoteClient) |
499 | { | 499 | { |
500 | Primitive prim = null; | 500 | Primitive prim = null; |
501 | foreach (EntityBase ent in Entities.Values) | 501 | foreach (EntityBase ent in Entities.Values) |
502 | { | 502 | { |
503 | if (ent is SceneObject) | 503 | if (ent is SceneObject) |
504 | { | 504 | { |
505 | prim = ((SceneObject)ent).HasChildPrim(localID); | 505 | prim = ((SceneObject)ent).HasChildPrim(localID); |
506 | if (prim != null) | 506 | if (prim != null) |
507 | { | 507 | { |
508 | prim.UpdateSinglePosition(pos); | 508 | prim.UpdateSinglePosition(pos); |
509 | break; | 509 | break; |
510 | } | 510 | } |
511 | } | 511 | } |
512 | } | 512 | } |
513 | } | 513 | } |
514 | 514 | ||
515 | /// <summary> | 515 | /// <summary> |
516 | /// | 516 | /// |
517 | /// </summary> | 517 | /// </summary> |
518 | /// <param name="localID"></param> | 518 | /// <param name="localID"></param> |
519 | /// <param name="pos"></param> | 519 | /// <param name="pos"></param> |
520 | /// <param name="rot"></param> | 520 | /// <param name="rot"></param> |
521 | /// <param name="remoteClient"></param> | 521 | /// <param name="remoteClient"></param> |
522 | public void UpdatePrimRotation(uint localID, LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient) | 522 | public void UpdatePrimRotation(uint localID, LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient) |
523 | { | 523 | { |
524 | Primitive prim = null; | 524 | Primitive prim = null; |
525 | foreach (EntityBase ent in Entities.Values) | 525 | foreach (EntityBase ent in Entities.Values) |
526 | { | 526 | { |
527 | if (ent is SceneObject) | 527 | if (ent is SceneObject) |
528 | { | 528 | { |
529 | prim = ((SceneObject)ent).HasChildPrim(localID); | 529 | prim = ((SceneObject)ent).HasChildPrim(localID); |
530 | if (prim != null) | 530 | if (prim != null) |
531 | { | 531 | { |
532 | prim.UpdateGroupMouseRotation(pos, rot); | 532 | prim.UpdateGroupMouseRotation(pos, rot); |
533 | break; | 533 | break; |
534 | } | 534 | } |
535 | } | 535 | } |
536 | } | 536 | } |
537 | } | 537 | } |
538 | 538 | ||
539 | /// <summary> | 539 | /// <summary> |
540 | /// | 540 | /// |
541 | /// </summary> | 541 | /// </summary> |
542 | /// <param name="localID"></param> | 542 | /// <param name="localID"></param> |
543 | /// <param name="rot"></param> | 543 | /// <param name="rot"></param> |
544 | /// <param name="remoteClient"></param> | 544 | /// <param name="remoteClient"></param> |
545 | public void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) | 545 | public void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) |
546 | { | 546 | { |
547 | Primitive prim = null; | 547 | Primitive prim = null; |
548 | foreach (EntityBase ent in Entities.Values) | 548 | foreach (EntityBase ent in Entities.Values) |
549 | { | 549 | { |
550 | if (ent is SceneObject) | 550 | if (ent is SceneObject) |
551 | { | 551 | { |
552 | prim = ((SceneObject)ent).HasChildPrim(localID); | 552 | prim = ((SceneObject)ent).HasChildPrim(localID); |
553 | if (prim != null) | 553 | if (prim != null) |
554 | { | 554 | { |
555 | prim.UpdateGroupRotation(rot); | 555 | prim.UpdateGroupRotation(rot); |
556 | break; | 556 | break; |
557 | } | 557 | } |
558 | } | 558 | } |
559 | } | 559 | } |
560 | } | 560 | } |
561 | 561 | ||
562 | /// <summary> | 562 | /// <summary> |
563 | /// | 563 | /// |
564 | /// </summary> | 564 | /// </summary> |
565 | /// <param name="localID"></param> | 565 | /// <param name="localID"></param> |
566 | /// <param name="rot"></param> | 566 | /// <param name="rot"></param> |
567 | /// <param name="remoteClient"></param> | 567 | /// <param name="remoteClient"></param> |
568 | public void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) | 568 | public void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) |
569 | { | 569 | { |
570 | //Console.WriteLine("trying to update single prim rotation"); | 570 | //Console.WriteLine("trying to update single prim rotation"); |
571 | Primitive prim = null; | 571 | Primitive prim = null; |
572 | foreach (EntityBase ent in Entities.Values) | 572 | foreach (EntityBase ent in Entities.Values) |
573 | { | 573 | { |
574 | if (ent is SceneObject) | 574 | if (ent is SceneObject) |
575 | { | 575 | { |
576 | prim = ((SceneObject)ent).HasChildPrim(localID); | 576 | prim = ((SceneObject)ent).HasChildPrim(localID); |
577 | if (prim != null) | 577 | if (prim != null) |
578 | { | 578 | { |
579 | prim.UpdateSingleRotation(rot); | 579 | prim.UpdateSingleRotation(rot); |
580 | break; | 580 | break; |
581 | } | 581 | } |
582 | } | 582 | } |
583 | } | 583 | } |
584 | } | 584 | } |
585 | 585 | ||
586 | /// <summary> | 586 | /// <summary> |
587 | /// | 587 | /// |
588 | /// </summary> | 588 | /// </summary> |
589 | /// <param name="localID"></param> | 589 | /// <param name="localID"></param> |
590 | /// <param name="scale"></param> | 590 | /// <param name="scale"></param> |
591 | /// <param name="remoteClient"></param> | 591 | /// <param name="remoteClient"></param> |
592 | public void UpdatePrimScale(uint localID, LLVector3 scale, IClientAPI remoteClient) | 592 | public void UpdatePrimScale(uint localID, LLVector3 scale, IClientAPI remoteClient) |
593 | { | 593 | { |
594 | Primitive prim = null; | 594 | Primitive prim = null; |
595 | foreach (EntityBase ent in Entities.Values) | 595 | foreach (EntityBase ent in Entities.Values) |
596 | { | 596 | { |
597 | if (ent is SceneObject) | 597 | if (ent is SceneObject) |
598 | { | 598 | { |
599 | prim = ((SceneObject)ent).HasChildPrim(localID); | 599 | prim = ((SceneObject)ent).HasChildPrim(localID); |
600 | if (prim != null) | 600 | if (prim != null) |
601 | { | 601 | { |
602 | prim.ResizeGoup(scale); | 602 | prim.ResizeGoup(scale); |
603 | break; | 603 | break; |
604 | } | 604 | } |
605 | } | 605 | } |
606 | } | 606 | } |
607 | } | 607 | } |
608 | 608 | ||
609 | /// <summary> | 609 | /// <summary> |
610 | /// Sends prims to a client | 610 | /// Sends prims to a client |
611 | /// </summary> | 611 | /// </summary> |
612 | /// <param name="RemoteClient">Client to send to</param> | 612 | /// <param name="RemoteClient">Client to send to</param> |
613 | public void GetInitialPrims(IClientAPI RemoteClient) | 613 | public void GetInitialPrims(IClientAPI RemoteClient) |
614 | { | 614 | { |
615 | 615 | ||
616 | } | 616 | } |
617 | } | 617 | } |
618 | } | 618 | } |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 1e69c9e..a06d74d 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -1,919 +1,919 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Threading; | 30 | using System.Threading; |
31 | using System.Timers; | 31 | using System.Timers; |
32 | using libsecondlife; | 32 | using libsecondlife; |
33 | using libsecondlife.Packets; | 33 | using libsecondlife.Packets; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Communications; | 35 | using OpenSim.Framework.Communications; |
36 | using OpenSim.Framework.Console; | 36 | using OpenSim.Framework.Console; |
37 | using OpenSim.Framework.Interfaces; | 37 | using OpenSim.Framework.Interfaces; |
38 | using OpenSim.Framework.Servers; | 38 | using OpenSim.Framework.Servers; |
39 | using OpenSim.Framework.Types; | 39 | using OpenSim.Framework.Types; |
40 | using OpenSim.Physics.Manager; | 40 | using OpenSim.Physics.Manager; |
41 | using OpenSim.Region.Caches; | 41 | using OpenSim.Region.Caches; |
42 | using OpenSim.Region.Interfaces; | 42 | using OpenSim.Region.Interfaces; |
43 | using OpenSim.Region.Scripting; | 43 | using OpenSim.Region.Scripting; |
44 | using OpenSim.Region.Terrain; | 44 | using OpenSim.Region.Terrain; |
45 | using Caps = OpenSim.Region.Capabilities.Caps; | 45 | using Caps = OpenSim.Region.Capabilities.Caps; |
46 | using Timer = System.Timers.Timer; | 46 | using Timer = System.Timers.Timer; |
47 | 47 | ||
48 | namespace OpenSim.Region.Environment.Scenes | 48 | namespace OpenSim.Region.Environment.Scenes |
49 | { | 49 | { |
50 | public delegate bool FilterAvatarList(ScenePresence avatar); | 50 | public delegate bool FilterAvatarList(ScenePresence avatar); |
51 | public delegate void ForEachScenePresenceDelegate(ScenePresence presence); | 51 | public delegate void ForEachScenePresenceDelegate(ScenePresence presence); |
52 | 52 | ||
53 | public partial class Scene : SceneBase, ILocalStorageReceiver | 53 | public partial class Scene : SceneBase, ILocalStorageReceiver |
54 | { | 54 | { |
55 | protected Timer m_heartbeatTimer = new Timer(); | 55 | protected Timer m_heartbeatTimer = new Timer(); |
56 | protected Dictionary<LLUUID, ScenePresence> Avatars; | 56 | protected Dictionary<LLUUID, ScenePresence> Avatars; |
57 | protected Dictionary<LLUUID, SceneObject> Prims; | 57 | protected Dictionary<LLUUID, SceneObject> Prims; |
58 | protected PhysicsScene phyScene; | 58 | protected PhysicsScene phyScene; |
59 | protected float timeStep = 0.1f; | 59 | protected float timeStep = 0.1f; |
60 | private Random Rand = new Random(); | 60 | private Random Rand = new Random(); |
61 | private uint _primCount = 702000; | 61 | private uint _primCount = 702000; |
62 | private System.Threading.Mutex _primAllocateMutex = new Mutex(false); | 62 | private System.Threading.Mutex _primAllocateMutex = new Mutex(false); |
63 | private int storageCount; | 63 | private int storageCount; |
64 | private int parcelPrimCheckCount; | 64 | private int parcelPrimCheckCount; |
65 | private Mutex updateLock; | 65 | private Mutex updateLock; |
66 | 66 | ||
67 | protected AuthenticateSessionsBase authenticateHandler; | 67 | protected AuthenticateSessionsBase authenticateHandler; |
68 | protected RegionCommsListener regionCommsHost; | 68 | protected RegionCommsListener regionCommsHost; |
69 | protected CommunicationsManager commsManager; | 69 | protected CommunicationsManager commsManager; |
70 | protected StorageManager storageManager; | 70 | protected StorageManager storageManager; |
71 | 71 | ||
72 | protected Dictionary<LLUUID, Caps> capsHandlers = new Dictionary<LLUUID, Caps>(); | 72 | protected Dictionary<LLUUID, Caps> capsHandlers = new Dictionary<LLUUID, Caps>(); |
73 | protected BaseHttpServer httpListener; | 73 | protected BaseHttpServer httpListener; |
74 | 74 | ||
75 | #region Properties | 75 | #region Properties |
76 | /// <summary> | 76 | /// <summary> |
77 | /// | 77 | /// |
78 | /// </summary> | 78 | /// </summary> |
79 | public PhysicsScene PhysScene | 79 | public PhysicsScene PhysScene |
80 | { | 80 | { |
81 | set | 81 | set |
82 | { | 82 | { |
83 | this.phyScene = value; | 83 | this.phyScene = value; |
84 | } | 84 | } |
85 | get | 85 | get |
86 | { | 86 | { |
87 | return (this.phyScene); | 87 | return (this.phyScene); |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | private ParcelManager m_parcelManager; | 91 | private ParcelManager m_parcelManager; |
92 | public ParcelManager ParcelManager | 92 | public ParcelManager ParcelManager |
93 | { | 93 | { |
94 | get { return m_parcelManager; } | 94 | get { return m_parcelManager; } |
95 | } | 95 | } |
96 | 96 | ||
97 | private EstateManager m_estateManager; | 97 | private EstateManager m_estateManager; |
98 | public EstateManager EstateManager | 98 | public EstateManager EstateManager |
99 | { | 99 | { |
100 | get { return m_estateManager; } | 100 | get { return m_estateManager; } |
101 | } | 101 | } |
102 | 102 | ||
103 | private EventManager m_eventManager; | 103 | private EventManager m_eventManager; |
104 | public EventManager EventManager | 104 | public EventManager EventManager |
105 | { | 105 | { |
106 | get { return m_eventManager; } | 106 | get { return m_eventManager; } |
107 | } | 107 | } |
108 | 108 | ||
109 | private ScriptManager m_scriptManager; | 109 | private ScriptManager m_scriptManager; |
110 | public ScriptManager ScriptManager | 110 | public ScriptManager ScriptManager |
111 | { | 111 | { |
112 | get { return m_scriptManager; } | 112 | get { return m_scriptManager; } |
113 | } | 113 | } |
114 | 114 | ||
115 | public Dictionary<LLUUID, SceneObject> Objects | 115 | public Dictionary<LLUUID, SceneObject> Objects |
116 | { | 116 | { |
117 | get { return Prims; } | 117 | get { return Prims; } |
118 | } | 118 | } |
119 | 119 | ||
120 | #endregion | 120 | #endregion |
121 | 121 | ||
122 | #region Constructors | 122 | #region Constructors |
123 | /// <summary> | 123 | /// <summary> |
124 | /// Creates a new World class, and a region to go with it. | 124 | /// Creates a new World class, and a region to go with it. |
125 | /// </summary> | 125 | /// </summary> |
126 | /// <param name="clientThreads">Dictionary to contain client threads</param> | 126 | /// <param name="clientThreads">Dictionary to contain client threads</param> |
127 | /// <param name="regionHandle">Region Handle for this region</param> | 127 | /// <param name="regionHandle">Region Handle for this region</param> |
128 | /// <param name="regionName">Region Name for this region</param> | 128 | /// <param name="regionName">Region Name for this region</param> |
129 | public Scene(RegionInfo regInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer) | 129 | public Scene(RegionInfo regInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer) |
130 | { | 130 | { |
131 | updateLock = new Mutex(false); | 131 | updateLock = new Mutex(false); |
132 | this.authenticateHandler = authen; | 132 | this.authenticateHandler = authen; |
133 | this.commsManager = commsMan; | 133 | this.commsManager = commsMan; |
134 | this.storageManager = storeManager; | 134 | this.storageManager = storeManager; |
135 | this.assetCache = assetCach; | 135 | this.assetCache = assetCach; |
136 | m_regInfo = regInfo; | 136 | m_regInfo = regInfo; |
137 | m_regionHandle = m_regInfo.RegionHandle; | 137 | m_regionHandle = m_regInfo.RegionHandle; |
138 | m_regionName = m_regInfo.RegionName; | 138 | m_regionName = m_regInfo.RegionName; |
139 | this.m_datastore = m_regInfo.DataStore; | 139 | this.m_datastore = m_regInfo.DataStore; |
140 | this.RegisterRegionWithComms(); | 140 | this.RegisterRegionWithComms(); |
141 | 141 | ||
142 | m_parcelManager = new ParcelManager(this, this.m_regInfo); | 142 | m_parcelManager = new ParcelManager(this, this.m_regInfo); |
143 | m_estateManager = new EstateManager(this, this.m_regInfo); | 143 | m_estateManager = new EstateManager(this, this.m_regInfo); |
144 | m_scriptManager = new ScriptManager(this); | 144 | m_scriptManager = new ScriptManager(this); |
145 | m_eventManager = new EventManager(); | 145 | m_eventManager = new EventManager(); |
146 | 146 | ||
147 | m_eventManager.OnParcelPrimCountAdd += new EventManager.OnParcelPrimCountAddDelegate(m_parcelManager.addPrimToParcelCounts); | 147 | m_eventManager.OnParcelPrimCountAdd += new EventManager.OnParcelPrimCountAddDelegate(m_parcelManager.addPrimToParcelCounts); |
148 | 148 | ||
149 | MainLog.Instance.Verbose("World.cs - creating new entitities instance"); | 149 | MainLog.Instance.Verbose("World.cs - creating new entitities instance"); |
150 | Entities = new Dictionary<LLUUID, EntityBase>(); | 150 | Entities = new Dictionary<LLUUID, EntityBase>(); |
151 | Avatars = new Dictionary<LLUUID, ScenePresence>(); | 151 | Avatars = new Dictionary<LLUUID, ScenePresence>(); |
152 | Prims = new Dictionary<LLUUID, SceneObject>(); | 152 | Prims = new Dictionary<LLUUID, SceneObject>(); |
153 | 153 | ||
154 | MainLog.Instance.Verbose("World.cs - loading objects from datastore"); | 154 | MainLog.Instance.Verbose("World.cs - loading objects from datastore"); |
155 | List<SceneObject> PrimsFromDB = storageManager.DataStore.LoadObjects(); | 155 | List<SceneObject> PrimsFromDB = storageManager.DataStore.LoadObjects(); |
156 | foreach (SceneObject prim in PrimsFromDB) | 156 | foreach (SceneObject prim in PrimsFromDB) |
157 | { | 157 | { |
158 | AddEntity(prim); | 158 | AddEntity(prim); |
159 | } | 159 | } |
160 | MainLog.Instance.Verbose("World.cs - loaded " + PrimsFromDB.Count.ToString() + " object(s)"); | 160 | MainLog.Instance.Verbose("World.cs - loaded " + PrimsFromDB.Count.ToString() + " object(s)"); |
161 | 161 | ||
162 | 162 | ||
163 | MainLog.Instance.Verbose("World.cs - creating LandMap"); | 163 | MainLog.Instance.Verbose("World.cs - creating LandMap"); |
164 | Terrain = new TerrainEngine(); | 164 | Terrain = new TerrainEngine(); |
165 | 165 | ||
166 | ScenePresence.LoadAnims(); | 166 | ScenePresence.LoadAnims(); |
167 | 167 | ||
168 | this.httpListener = httpServer; | 168 | this.httpListener = httpServer; |
169 | } | 169 | } |
170 | #endregion | 170 | #endregion |
171 | 171 | ||
172 | #region Script Handling Methods | 172 | #region Script Handling Methods |
173 | 173 | ||
174 | public void SendCommandToScripts(string[] args) | 174 | public void SendCommandToScripts(string[] args) |
175 | { | 175 | { |
176 | m_eventManager.TriggerOnScriptConsole(args); | 176 | m_eventManager.TriggerOnScriptConsole(args); |
177 | } | 177 | } |
178 | 178 | ||
179 | #endregion | 179 | #endregion |
180 | 180 | ||
181 | /// <summary> | 181 | /// <summary> |
182 | /// | 182 | /// |
183 | /// </summary> | 183 | /// </summary> |
184 | public void StartTimer() | 184 | public void StartTimer() |
185 | { | 185 | { |
186 | m_heartbeatTimer.Enabled = true; | 186 | m_heartbeatTimer.Enabled = true; |
187 | m_heartbeatTimer.Interval = 100; | 187 | m_heartbeatTimer.Interval = 100; |
188 | m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat); | 188 | m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat); |
189 | } | 189 | } |
190 | 190 | ||
191 | 191 | ||
192 | #region Update Methods | 192 | #region Update Methods |
193 | 193 | ||
194 | 194 | ||
195 | /// <summary> | 195 | /// <summary> |
196 | /// Performs per-frame updates regularly | 196 | /// Performs per-frame updates regularly |
197 | /// </summary> | 197 | /// </summary> |
198 | /// <param name="sender"></param> | 198 | /// <param name="sender"></param> |
199 | /// <param name="e"></param> | 199 | /// <param name="e"></param> |
200 | void Heartbeat(object sender, EventArgs e) | 200 | void Heartbeat(object sender, EventArgs e) |
201 | { | 201 | { |
202 | this.Update(); | 202 | this.Update(); |
203 | } | 203 | } |
204 | 204 | ||
205 | /// <summary> | 205 | /// <summary> |
206 | /// Performs per-frame updates on the world, this should be the central world loop | 206 | /// Performs per-frame updates on the world, this should be the central world loop |
207 | /// </summary> | 207 | /// </summary> |
208 | public override void Update() | 208 | public override void Update() |
209 | { | 209 | { |
210 | updateLock.WaitOne(); | 210 | updateLock.WaitOne(); |
211 | try | 211 | try |
212 | { | 212 | { |
213 | if (this.phyScene.IsThreaded) | 213 | if (this.phyScene.IsThreaded) |
214 | { | 214 | { |
215 | this.phyScene.GetResults(); | 215 | this.phyScene.GetResults(); |
216 | 216 | ||
217 | } | 217 | } |
218 | 218 | ||
219 | foreach (LLUUID UUID in Entities.Keys) | 219 | foreach (LLUUID UUID in Entities.Keys) |
220 | { | 220 | { |
221 | Entities[UUID].updateMovement(); | 221 | Entities[UUID].updateMovement(); |
222 | } | 222 | } |
223 | 223 | ||
224 | lock (this.m_syncRoot) | 224 | lock (this.m_syncRoot) |
225 | { | 225 | { |
226 | this.phyScene.Simulate(timeStep); | 226 | this.phyScene.Simulate(timeStep); |
227 | } | 227 | } |
228 | 228 | ||
229 | foreach (LLUUID UUID in Entities.Keys) | 229 | foreach (LLUUID UUID in Entities.Keys) |
230 | { | 230 | { |
231 | Entities[UUID].update(); | 231 | Entities[UUID].update(); |
232 | } | 232 | } |
233 | 233 | ||
234 | // General purpose event manager | 234 | // General purpose event manager |
235 | m_eventManager.TriggerOnFrame(); | 235 | m_eventManager.TriggerOnFrame(); |
236 | 236 | ||
237 | //backup world data | 237 | //backup world data |
238 | this.storageCount++; | 238 | this.storageCount++; |
239 | if (storageCount > 1200) //set to how often you want to backup | 239 | if (storageCount > 1200) //set to how often you want to backup |
240 | { | 240 | { |
241 | this.Backup(); | 241 | this.Backup(); |
242 | storageCount = 0; | 242 | storageCount = 0; |
243 | } | 243 | } |
244 | 244 | ||
245 | this.parcelPrimCheckCount++; | 245 | this.parcelPrimCheckCount++; |
246 | if (this.parcelPrimCheckCount > 50) //check every 5 seconds for tainted prims | 246 | if (this.parcelPrimCheckCount > 50) //check every 5 seconds for tainted prims |
247 | { | 247 | { |
248 | if (m_parcelManager.parcelPrimCountTainted) | 248 | if (m_parcelManager.parcelPrimCountTainted) |
249 | { | 249 | { |
250 | //Perform parcel update of prim count | 250 | //Perform parcel update of prim count |
251 | performParcelPrimCountUpdate(); | 251 | performParcelPrimCountUpdate(); |
252 | this.parcelPrimCheckCount = 0; | 252 | this.parcelPrimCheckCount = 0; |
253 | } | 253 | } |
254 | } | 254 | } |
255 | 255 | ||
256 | } | 256 | } |
257 | catch (Exception e) | 257 | catch (Exception e) |
258 | { | 258 | { |
259 | MainLog.Instance.Warn("World.cs: Update() - Failed with exception " + e.ToString()); | 259 | MainLog.Instance.Warn("World.cs: Update() - Failed with exception " + e.ToString()); |
260 | } | 260 | } |
261 | updateLock.ReleaseMutex(); | 261 | updateLock.ReleaseMutex(); |
262 | 262 | ||
263 | } | 263 | } |
264 | 264 | ||
265 | /// <summary> | 265 | /// <summary> |
266 | /// | 266 | /// |
267 | /// </summary> | 267 | /// </summary> |
268 | /// <returns></returns> | 268 | /// <returns></returns> |
269 | public bool Backup() | 269 | public bool Backup() |
270 | { | 270 | { |
271 | EventManager.TriggerOnBackup(this.storageManager.DataStore); | 271 | EventManager.TriggerOnBackup(this.storageManager.DataStore); |
272 | return true; | 272 | return true; |
273 | } | 273 | } |
274 | #endregion | 274 | #endregion |
275 | 275 | ||
276 | #region Regenerate Terrain | 276 | #region Regenerate Terrain |
277 | 277 | ||
278 | /// <summary> | 278 | /// <summary> |
279 | /// Rebuilds the terrain using a procedural algorithm | 279 | /// Rebuilds the terrain using a procedural algorithm |
280 | /// </summary> | 280 | /// </summary> |
281 | public void RegenerateTerrain() | 281 | public void RegenerateTerrain() |
282 | { | 282 | { |
283 | try | 283 | try |
284 | { | 284 | { |
285 | Terrain.hills(); | 285 | Terrain.hills(); |
286 | 286 | ||
287 | lock (this.m_syncRoot) | 287 | lock (this.m_syncRoot) |
288 | { | 288 | { |
289 | this.phyScene.SetTerrain(Terrain.getHeights1D()); | 289 | this.phyScene.SetTerrain(Terrain.getHeights1D()); |
290 | } | 290 | } |
291 | 291 | ||
292 | this.storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD()); | 292 | this.storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD()); |
293 | 293 | ||
294 | this.ForEachScenePresence(delegate(ScenePresence presence) | 294 | this.ForEachScenePresence(delegate(ScenePresence presence) |
295 | { | 295 | { |
296 | this.SendLayerData(presence.ControllingClient); | 296 | this.SendLayerData(presence.ControllingClient); |
297 | }); | 297 | }); |
298 | 298 | ||
299 | foreach (LLUUID UUID in Entities.Keys) | 299 | foreach (LLUUID UUID in Entities.Keys) |
300 | { | 300 | { |
301 | Entities[UUID].LandRenegerated(); | 301 | Entities[UUID].LandRenegerated(); |
302 | } | 302 | } |
303 | } | 303 | } |
304 | catch (Exception e) | 304 | catch (Exception e) |
305 | { | 305 | { |
306 | MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString()); | 306 | MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString()); |
307 | } | 307 | } |
308 | } | 308 | } |
309 | 309 | ||
310 | /// <summary> | 310 | /// <summary> |
311 | /// Rebuilds the terrain using a 2D float array | 311 | /// Rebuilds the terrain using a 2D float array |
312 | /// </summary> | 312 | /// </summary> |
313 | /// <param name="newMap">256,256 float array containing heights</param> | 313 | /// <param name="newMap">256,256 float array containing heights</param> |
314 | public void RegenerateTerrain(float[,] newMap) | 314 | public void RegenerateTerrain(float[,] newMap) |
315 | { | 315 | { |
316 | try | 316 | try |
317 | { | 317 | { |
318 | this.Terrain.setHeights2D(newMap); | 318 | this.Terrain.setHeights2D(newMap); |
319 | lock (this.m_syncRoot) | 319 | lock (this.m_syncRoot) |
320 | { | 320 | { |
321 | this.phyScene.SetTerrain(this.Terrain.getHeights1D()); | 321 | this.phyScene.SetTerrain(this.Terrain.getHeights1D()); |
322 | } | 322 | } |
323 | this.storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD()); | 323 | this.storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD()); |
324 | 324 | ||
325 | this.ForEachScenePresence(delegate(ScenePresence presence) | 325 | this.ForEachScenePresence(delegate(ScenePresence presence) |
326 | { | 326 | { |
327 | this.SendLayerData(presence.ControllingClient); | 327 | this.SendLayerData(presence.ControllingClient); |
328 | }); | 328 | }); |
329 | 329 | ||
330 | foreach (LLUUID UUID in Entities.Keys) | 330 | foreach (LLUUID UUID in Entities.Keys) |
331 | { | 331 | { |
332 | Entities[UUID].LandRenegerated(); | 332 | Entities[UUID].LandRenegerated(); |
333 | } | 333 | } |
334 | } | 334 | } |
335 | catch (Exception e) | 335 | catch (Exception e) |
336 | { | 336 | { |
337 | MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString()); | 337 | MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString()); |
338 | } | 338 | } |
339 | } | 339 | } |
340 | 340 | ||
341 | /// <summary> | 341 | /// <summary> |
342 | /// Rebuilds the terrain assuming changes occured at a specified point[?] | 342 | /// Rebuilds the terrain assuming changes occured at a specified point[?] |
343 | /// </summary> | 343 | /// </summary> |
344 | /// <param name="changes">???</param> | 344 | /// <param name="changes">???</param> |
345 | /// <param name="pointx">???</param> | 345 | /// <param name="pointx">???</param> |
346 | /// <param name="pointy">???</param> | 346 | /// <param name="pointy">???</param> |
347 | public void RegenerateTerrain(bool changes, int pointx, int pointy) | 347 | public void RegenerateTerrain(bool changes, int pointx, int pointy) |
348 | { | 348 | { |
349 | try | 349 | try |
350 | { | 350 | { |
351 | if (changes) | 351 | if (changes) |
352 | { | 352 | { |
353 | /* Dont save here, rely on tainting system instead */ | 353 | /* Dont save here, rely on tainting system instead */ |
354 | 354 | ||
355 | this.ForEachScenePresence(delegate(ScenePresence presence) | 355 | this.ForEachScenePresence(delegate(ScenePresence presence) |
356 | { | 356 | { |
357 | this.SendLayerData(pointx, pointy, presence.ControllingClient); | 357 | this.SendLayerData(pointx, pointy, presence.ControllingClient); |
358 | }); | 358 | }); |
359 | } | 359 | } |
360 | } | 360 | } |
361 | catch (Exception e) | 361 | catch (Exception e) |
362 | { | 362 | { |
363 | MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString()); | 363 | MainLog.Instance.Warn("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString()); |
364 | } | 364 | } |
365 | } | 365 | } |
366 | 366 | ||
367 | #endregion | 367 | #endregion |
368 | 368 | ||
369 | #region Load Terrain | 369 | #region Load Terrain |
370 | /// <summary> | 370 | /// <summary> |
371 | /// Loads the World heightmap | 371 | /// Loads the World heightmap |
372 | /// </summary> | 372 | /// </summary> |
373 | /// | 373 | /// |
374 | public override void LoadWorldMap() | 374 | public override void LoadWorldMap() |
375 | { | 375 | { |
376 | try | 376 | try |
377 | { | 377 | { |
378 | double[,] map = this.storageManager.DataStore.LoadTerrain(); | 378 | double[,] map = this.storageManager.DataStore.LoadTerrain(); |
379 | if (map == null) | 379 | if (map == null) |
380 | { | 380 | { |
381 | if (string.IsNullOrEmpty(this.m_regInfo.estateSettings.terrainFile)) | 381 | if (string.IsNullOrEmpty(this.m_regInfo.estateSettings.terrainFile)) |
382 | { | 382 | { |
383 | Console.WriteLine("No default terrain, procedurally generating..."); | 383 | Console.WriteLine("No default terrain, procedurally generating..."); |
384 | this.Terrain.hills(); | 384 | this.Terrain.hills(); |
385 | 385 | ||
386 | this.storageManager.DataStore.StoreTerrain(this.Terrain.getHeights2DD()); | 386 | this.storageManager.DataStore.StoreTerrain(this.Terrain.getHeights2DD()); |
387 | } | 387 | } |
388 | else | 388 | else |
389 | { | 389 | { |
390 | try | 390 | try |
391 | { | 391 | { |
392 | this.Terrain.loadFromFileF32(this.m_regInfo.estateSettings.terrainFile); | 392 | this.Terrain.loadFromFileF32(this.m_regInfo.estateSettings.terrainFile); |
393 | this.Terrain *= this.m_regInfo.estateSettings.terrainMultiplier; | 393 | this.Terrain *= this.m_regInfo.estateSettings.terrainMultiplier; |
394 | } | 394 | } |
395 | catch | 395 | catch |
396 | { | 396 | { |
397 | Console.WriteLine("Unable to load default terrain, procedurally generating instead..."); | 397 | Console.WriteLine("Unable to load default terrain, procedurally generating instead..."); |
398 | Terrain.hills(); | 398 | Terrain.hills(); |
399 | } | 399 | } |
400 | this.storageManager.DataStore.StoreTerrain(this.Terrain.getHeights2DD()); | 400 | this.storageManager.DataStore.StoreTerrain(this.Terrain.getHeights2DD()); |
401 | } | 401 | } |
402 | } | 402 | } |
403 | else | 403 | else |
404 | { | 404 | { |
405 | this.Terrain.setHeights2D(map); | 405 | this.Terrain.setHeights2D(map); |
406 | } | 406 | } |
407 | 407 | ||
408 | CreateTerrainTexture(); | 408 | CreateTerrainTexture(); |
409 | 409 | ||
410 | } | 410 | } |
411 | catch (Exception e) | 411 | catch (Exception e) |
412 | { | 412 | { |
413 | MainLog.Instance.Warn("World.cs: LoadWorldMap() - Failed with exception " + e.ToString()); | 413 | MainLog.Instance.Warn("World.cs: LoadWorldMap() - Failed with exception " + e.ToString()); |
414 | } | 414 | } |
415 | } | 415 | } |
416 | 416 | ||
417 | /// <summary> | 417 | /// <summary> |
418 | /// | 418 | /// |
419 | /// </summary> | 419 | /// </summary> |
420 | public void CreateTerrainTexture() | 420 | public void CreateTerrainTexture() |
421 | { | 421 | { |
422 | //create a texture asset of the terrain | 422 | //create a texture asset of the terrain |
423 | byte[] data = this.Terrain.exportJpegImage("defaultstripe.png"); | 423 | byte[] data = this.Terrain.exportJpegImage("defaultstripe.png"); |
424 | this.m_regInfo.estateSettings.terrainImageID = LLUUID.Random(); | 424 | this.m_regInfo.estateSettings.terrainImageID = LLUUID.Random(); |
425 | AssetBase asset = new AssetBase(); | 425 | AssetBase asset = new AssetBase(); |
426 | asset.FullID = this.m_regInfo.estateSettings.terrainImageID; | 426 | asset.FullID = this.m_regInfo.estateSettings.terrainImageID; |
427 | asset.Data = data; | 427 | asset.Data = data; |
428 | asset.Name = "terrainImage"; | 428 | asset.Name = "terrainImage"; |
429 | asset.Type = 0; | 429 | asset.Type = 0; |
430 | this.assetCache.AddAsset(asset); | 430 | this.assetCache.AddAsset(asset); |
431 | } | 431 | } |
432 | #endregion | 432 | #endregion |
433 | 433 | ||
434 | #region Primitives Methods | 434 | #region Primitives Methods |
435 | 435 | ||
436 | 436 | ||
437 | /// <summary> | 437 | /// <summary> |
438 | /// Loads the World's objects | 438 | /// Loads the World's objects |
439 | /// </summary> | 439 | /// </summary> |
440 | public void LoadPrimsFromStorage() | 440 | public void LoadPrimsFromStorage() |
441 | { | 441 | { |
442 | try | 442 | try |
443 | { | 443 | { |
444 | MainLog.Instance.Verbose("World.cs: LoadPrimsFromStorage() - Loading primitives"); | 444 | MainLog.Instance.Verbose("World.cs: LoadPrimsFromStorage() - Loading primitives"); |
445 | this.localStorage.LoadPrimitives(this); | 445 | this.localStorage.LoadPrimitives(this); |
446 | } | 446 | } |
447 | catch (Exception e) | 447 | catch (Exception e) |
448 | { | 448 | { |
449 | MainLog.Instance.Warn("World.cs: LoadPrimsFromStorage() - Failed with exception " + e.ToString()); | 449 | MainLog.Instance.Warn("World.cs: LoadPrimsFromStorage() - Failed with exception " + e.ToString()); |
450 | } | 450 | } |
451 | } | 451 | } |
452 | 452 | ||
453 | /// <summary> | 453 | /// <summary> |
454 | /// Loads a specific object from storage | 454 | /// Loads a specific object from storage |
455 | /// </summary> | 455 | /// </summary> |
456 | /// <param name="prim">The object to load</param> | 456 | /// <param name="prim">The object to load</param> |
457 | public void PrimFromStorage(PrimData prim) | 457 | public void PrimFromStorage(PrimData prim) |
458 | { | 458 | { |
459 | } | 459 | } |
460 | 460 | ||
461 | /// <summary> | 461 | /// <summary> |
462 | /// Returns a new unallocated primitive ID | 462 | /// Returns a new unallocated primitive ID |
463 | /// </summary> | 463 | /// </summary> |
464 | /// <returns>A brand new primitive ID</returns> | 464 | /// <returns>A brand new primitive ID</returns> |
465 | public uint PrimIDAllocate() | 465 | public uint PrimIDAllocate() |
466 | { | 466 | { |
467 | uint myID; | 467 | uint myID; |
468 | 468 | ||
469 | _primAllocateMutex.WaitOne(); | 469 | _primAllocateMutex.WaitOne(); |
470 | ++_primCount; | 470 | ++_primCount; |
471 | myID = _primCount; | 471 | myID = _primCount; |
472 | _primAllocateMutex.ReleaseMutex(); | 472 | _primAllocateMutex.ReleaseMutex(); |
473 | 473 | ||
474 | return myID; | 474 | return myID; |
475 | } | 475 | } |
476 | 476 | ||
477 | /// <summary> | 477 | /// <summary> |
478 | /// | 478 | /// |
479 | /// </summary> | 479 | /// </summary> |
480 | /// <param name="addPacket"></param> | 480 | /// <param name="addPacket"></param> |
481 | /// <param name="ownerID"></param> | 481 | /// <param name="ownerID"></param> |
482 | public void AddNewPrim(LLUUID ownerID, LLVector3 pos, PrimitiveBaseShape shape) | 482 | public void AddNewPrim(LLUUID ownerID, LLVector3 pos, PrimitiveBaseShape shape) |
483 | { | 483 | { |
484 | 484 | ||
485 | SceneObject sceneOb = new SceneObject(this, m_eventManager, ownerID, this.PrimIDAllocate(), pos, shape); | 485 | SceneObject sceneOb = new SceneObject(this, m_eventManager, ownerID, this.PrimIDAllocate(), pos, shape); |
486 | AddEntity(sceneOb); | 486 | AddEntity(sceneOb); |
487 | } | 487 | } |
488 | 488 | ||
489 | public void RemovePrim(uint localID, LLUUID avatar_deleter) | 489 | public void RemovePrim(uint localID, LLUUID avatar_deleter) |
490 | { | 490 | { |
491 | foreach (EntityBase obj in Entities.Values) | 491 | foreach (EntityBase obj in Entities.Values) |
492 | { | 492 | { |
493 | if (obj is SceneObject) | 493 | if (obj is SceneObject) |
494 | { | 494 | { |
495 | if (((SceneObject)obj).LocalId == localID) | 495 | if (((SceneObject)obj).LocalId == localID) |
496 | { | 496 | { |
497 | RemoveEntity((SceneObject)obj); | 497 | RemoveEntity((SceneObject)obj); |
498 | return; | 498 | return; |
499 | } | 499 | } |
500 | } | 500 | } |
501 | } | 501 | } |
502 | 502 | ||
503 | } | 503 | } |
504 | 504 | ||
505 | public void AddEntity(SceneObject sceneObject) | 505 | public void AddEntity(SceneObject sceneObject) |
506 | { | 506 | { |
507 | this.Entities.Add(sceneObject.rootUUID, sceneObject); | 507 | this.Entities.Add(sceneObject.rootUUID, sceneObject); |
508 | } | 508 | } |
509 | 509 | ||
510 | public void RemoveEntity(SceneObject sceneObject) | 510 | public void RemoveEntity(SceneObject sceneObject) |
511 | { | 511 | { |
512 | if (this.Entities.ContainsKey(sceneObject.rootUUID)) | 512 | if (this.Entities.ContainsKey(sceneObject.rootUUID)) |
513 | { | 513 | { |
514 | m_parcelManager.removePrimFromParcelCounts(sceneObject); | 514 | m_parcelManager.removePrimFromParcelCounts(sceneObject); |
515 | this.Entities.Remove(sceneObject.rootUUID); | 515 | this.Entities.Remove(sceneObject.rootUUID); |
516 | m_parcelManager.setPrimsTainted(); | 516 | m_parcelManager.setPrimsTainted(); |
517 | } | 517 | } |
518 | } | 518 | } |
519 | 519 | ||
520 | /// <summary> | 520 | /// <summary> |
521 | /// Called by a prim when it has been created/cloned, so that its events can be subscribed to | 521 | /// Called by a prim when it has been created/cloned, so that its events can be subscribed to |
522 | /// </summary> | 522 | /// </summary> |
523 | /// <param name="prim"></param> | 523 | /// <param name="prim"></param> |
524 | public void AcknowledgeNewPrim(Primitive prim) | 524 | public void AcknowledgeNewPrim(Primitive prim) |
525 | { | 525 | { |
526 | prim.OnPrimCountTainted += m_parcelManager.setPrimsTainted; | 526 | prim.OnPrimCountTainted += m_parcelManager.setPrimsTainted; |
527 | } | 527 | } |
528 | #endregion | 528 | #endregion |
529 | 529 | ||
530 | #region Add/Remove Avatar Methods | 530 | #region Add/Remove Avatar Methods |
531 | 531 | ||
532 | /// <summary> | 532 | /// <summary> |
533 | /// | 533 | /// |
534 | /// </summary> | 534 | /// </summary> |
535 | /// <param name="remoteClient"></param | 535 | /// <param name="remoteClient"></param |
536 | /// <param name="agentID"></param> | 536 | /// <param name="agentID"></param> |
537 | /// <param name="child"></param> | 537 | /// <param name="child"></param> |
538 | public override void AddNewClient(IClientAPI client, bool child) | 538 | public override void AddNewClient(IClientAPI client, bool child) |
539 | { | 539 | { |
540 | SubscribeToClientEvents(client); | 540 | SubscribeToClientEvents(client); |
541 | this.m_estateManager.sendRegionHandshake(client); | 541 | this.m_estateManager.sendRegionHandshake(client); |
542 | CreateAndAddScenePresence(client); | 542 | CreateAndAddScenePresence(client); |
543 | this.m_parcelManager.sendParcelOverlay(client); | 543 | this.m_parcelManager.sendParcelOverlay(client); |
544 | 544 | ||
545 | } | 545 | } |
546 | 546 | ||
547 | protected virtual void SubscribeToClientEvents(IClientAPI client) | 547 | protected virtual void SubscribeToClientEvents(IClientAPI client) |
548 | { | 548 | { |
549 | client.OnRegionHandShakeReply += this.SendLayerData; | 549 | client.OnRegionHandShakeReply += this.SendLayerData; |
550 | //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims); | 550 | //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims); |
551 | client.OnChatFromViewer += this.SimChat; | 551 | client.OnChatFromViewer += this.SimChat; |
552 | client.OnInstantMessage += this.InstantMessage; | 552 | client.OnInstantMessage += this.InstantMessage; |
553 | client.OnRequestWearables += this.InformClientOfNeighbours; | 553 | client.OnRequestWearables += this.InformClientOfNeighbours; |
554 | client.OnAddPrim += this.AddNewPrim; | 554 | client.OnAddPrim += this.AddNewPrim; |
555 | client.OnUpdatePrimGroupPosition += this.UpdatePrimPosition; | 555 | client.OnUpdatePrimGroupPosition += this.UpdatePrimPosition; |
556 | client.OnUpdatePrimSinglePosition += this.UpdatePrimSinglePosition; | 556 | client.OnUpdatePrimSinglePosition += this.UpdatePrimSinglePosition; |
557 | client.OnUpdatePrimGroupRotation += this.UpdatePrimRotation; | 557 | client.OnUpdatePrimGroupRotation += this.UpdatePrimRotation; |
558 | client.OnUpdatePrimGroupMouseRotation += this.UpdatePrimRotation; | 558 | client.OnUpdatePrimGroupMouseRotation += this.UpdatePrimRotation; |
559 | client.OnUpdatePrimSingleRotation += this.UpdatePrimSingleRotation; | 559 | client.OnUpdatePrimSingleRotation += this.UpdatePrimSingleRotation; |
560 | client.OnUpdatePrimScale += this.UpdatePrimScale; | 560 | client.OnUpdatePrimScale += this.UpdatePrimScale; |
561 | client.OnUpdatePrimShape += this.UpdatePrimShape; | 561 | client.OnUpdatePrimShape += this.UpdatePrimShape; |
562 | client.OnRequestMapBlocks += this.RequestMapBlocks; | 562 | client.OnRequestMapBlocks += this.RequestMapBlocks; |
563 | client.OnUpdatePrimTexture += this.UpdatePrimTexture; | 563 | client.OnUpdatePrimTexture += this.UpdatePrimTexture; |
564 | client.OnTeleportLocationRequest += this.RequestTeleportLocation; | 564 | client.OnTeleportLocationRequest += this.RequestTeleportLocation; |
565 | client.OnObjectSelect += this.SelectPrim; | 565 | client.OnObjectSelect += this.SelectPrim; |
566 | client.OnObjectDeselect += this.DeselectPrim; | 566 | client.OnObjectDeselect += this.DeselectPrim; |
567 | client.OnGrapUpdate += this.MoveObject; | 567 | client.OnGrapUpdate += this.MoveObject; |
568 | client.OnNameFromUUIDRequest += this.commsManager.HandleUUIDNameRequest; | 568 | client.OnNameFromUUIDRequest += this.commsManager.HandleUUIDNameRequest; |
569 | client.OnObjectDescription += this.PrimDescription; | 569 | client.OnObjectDescription += this.PrimDescription; |
570 | client.OnObjectName += this.PrimName; | 570 | client.OnObjectName += this.PrimName; |
571 | client.OnLinkObjects += this.LinkObjects; | 571 | client.OnLinkObjects += this.LinkObjects; |
572 | client.OnObjectDuplicate += this.DuplicateObject; | 572 | client.OnObjectDuplicate += this.DuplicateObject; |
573 | 573 | ||
574 | client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(m_parcelManager.handleParcelPropertiesRequest); | 574 | client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(m_parcelManager.handleParcelPropertiesRequest); |
575 | client.OnParcelDivideRequest += new ParcelDivideRequest(m_parcelManager.handleParcelDivideRequest); | 575 | client.OnParcelDivideRequest += new ParcelDivideRequest(m_parcelManager.handleParcelDivideRequest); |
576 | client.OnParcelJoinRequest += new ParcelJoinRequest(m_parcelManager.handleParcelJoinRequest); | 576 | client.OnParcelJoinRequest += new ParcelJoinRequest(m_parcelManager.handleParcelJoinRequest); |
577 | client.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(m_parcelManager.handleParcelPropertiesUpdateRequest); | 577 | client.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(m_parcelManager.handleParcelPropertiesUpdateRequest); |
578 | client.OnParcelSelectObjects += new ParcelSelectObjects(m_parcelManager.handleParcelSelectObjectsRequest); | 578 | client.OnParcelSelectObjects += new ParcelSelectObjects(m_parcelManager.handleParcelSelectObjectsRequest); |
579 | client.OnParcelObjectOwnerRequest += new ParcelObjectOwnerRequest(m_parcelManager.handleParcelObjectOwnersRequest); | 579 | client.OnParcelObjectOwnerRequest += new ParcelObjectOwnerRequest(m_parcelManager.handleParcelObjectOwnersRequest); |
580 | 580 | ||
581 | client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage); | 581 | client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage); |
582 | 582 | ||
583 | } | 583 | } |
584 | 584 | ||
585 | protected ScenePresence CreateAndAddScenePresence(IClientAPI client) | 585 | protected ScenePresence CreateAndAddScenePresence(IClientAPI client) |
586 | { | 586 | { |
587 | ScenePresence newAvatar = null; | 587 | ScenePresence newAvatar = null; |
588 | 588 | ||
589 | MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); | 589 | MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); |
590 | newAvatar = new ScenePresence(client, this, this.m_regInfo); | 590 | newAvatar = new ScenePresence(client, this, this.m_regInfo); |
591 | MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Adding new avatar to world"); | 591 | MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Adding new avatar to world"); |
592 | MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Starting RegionHandshake "); | 592 | MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Starting RegionHandshake "); |
593 | 593 | ||
594 | PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z); | 594 | PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z); |
595 | lock (this.m_syncRoot) | 595 | lock (this.m_syncRoot) |
596 | { | 596 | { |
597 | newAvatar.PhysActor = this.phyScene.AddAvatar(pVec); | 597 | newAvatar.PhysActor = this.phyScene.AddAvatar(pVec); |
598 | } | 598 | } |
599 | 599 | ||
600 | lock (Entities) | 600 | lock (Entities) |
601 | { | 601 | { |
602 | if (!Entities.ContainsKey(client.AgentId)) | 602 | if (!Entities.ContainsKey(client.AgentId)) |
603 | { | 603 | { |
604 | this.Entities.Add(client.AgentId, newAvatar); | 604 | this.Entities.Add(client.AgentId, newAvatar); |
605 | } | 605 | } |
606 | else | 606 | else |
607 | { | 607 | { |
608 | Entities[client.AgentId] = newAvatar; | 608 | Entities[client.AgentId] = newAvatar; |
609 | } | 609 | } |
610 | } | 610 | } |
611 | lock (Avatars) | 611 | lock (Avatars) |
612 | { | 612 | { |
613 | if (Avatars.ContainsKey(client.AgentId)) | 613 | if (Avatars.ContainsKey(client.AgentId)) |
614 | { | 614 | { |
615 | Avatars[client.AgentId] = newAvatar; | 615 | Avatars[client.AgentId] = newAvatar; |
616 | } | 616 | } |
617 | else | 617 | else |
618 | { | 618 | { |
619 | this.Avatars.Add(client.AgentId, newAvatar); | 619 | this.Avatars.Add(client.AgentId, newAvatar); |
620 | } | 620 | } |
621 | } | 621 | } |
622 | newAvatar.OnSignificantClientMovement += m_parcelManager.handleSignificantClientMovement; | 622 | newAvatar.OnSignificantClientMovement += m_parcelManager.handleSignificantClientMovement; |
623 | return newAvatar; | 623 | return newAvatar; |
624 | } | 624 | } |
625 | 625 | ||
626 | 626 | ||
627 | /// <summary> | 627 | /// <summary> |
628 | /// | 628 | /// |
629 | /// </summary> | 629 | /// </summary> |
630 | /// <param name="agentID"></param> | 630 | /// <param name="agentID"></param> |
631 | public override void RemoveClient(LLUUID agentID) | 631 | public override void RemoveClient(LLUUID agentID) |
632 | { | 632 | { |
633 | m_eventManager.TriggerOnRemovePresence(agentID); | 633 | m_eventManager.TriggerOnRemovePresence(agentID); |
634 | 634 | ||
635 | ScenePresence avatar = this.RequestAvatar(agentID); | 635 | ScenePresence avatar = this.RequestAvatar(agentID); |
636 | 636 | ||
637 | this.ForEachScenePresence( | 637 | this.ForEachScenePresence( |
638 | delegate(ScenePresence presence) | 638 | delegate(ScenePresence presence) |
639 | { | 639 | { |
640 | presence.ControllingClient.SendKillObject(avatar.RegionHandle, avatar.LocalId); | 640 | presence.ControllingClient.SendKillObject(avatar.RegionHandle, avatar.LocalId); |
641 | }); | 641 | }); |
642 | 642 | ||
643 | lock (Avatars) | 643 | lock (Avatars) |
644 | { | 644 | { |
645 | if (Avatars.ContainsKey(agentID)) | 645 | if (Avatars.ContainsKey(agentID)) |
646 | { | 646 | { |
647 | Avatars.Remove(agentID); | 647 | Avatars.Remove(agentID); |
648 | } | 648 | } |
649 | } | 649 | } |
650 | lock (Entities) | 650 | lock (Entities) |
651 | { | 651 | { |
652 | if (Entities.ContainsKey(agentID)) | 652 | if (Entities.ContainsKey(agentID)) |
653 | { | 653 | { |
654 | Entities.Remove(agentID); | 654 | Entities.Remove(agentID); |
655 | } | 655 | } |
656 | } | 656 | } |
657 | // TODO: Add the removal from physics ? | 657 | // TODO: Add the removal from physics ? |
658 | 658 | ||
659 | 659 | ||
660 | 660 | ||
661 | return; | 661 | return; |
662 | } | 662 | } |
663 | #endregion | 663 | #endregion |
664 | 664 | ||
665 | #region Request Avatars List Methods | 665 | #region Request Avatars List Methods |
666 | //The idea is to have a group of method that return a list of avatars meeting some requirement | 666 | //The idea is to have a group of method that return a list of avatars meeting some requirement |
667 | // ie it could be all Avatars within a certain range of the calling prim/avatar. | 667 | // ie it could be all Avatars within a certain range of the calling prim/avatar. |
668 | 668 | ||
669 | /// <summary> | 669 | /// <summary> |
670 | /// Request a List of all Avatars in this World | 670 | /// Request a List of all Avatars in this World |
671 | /// </summary> | 671 | /// </summary> |
672 | /// <returns></returns> | 672 | /// <returns></returns> |
673 | public List<ScenePresence> RequestAvatarList() | 673 | public List<ScenePresence> RequestAvatarList() |
674 | { | 674 | { |
675 | List<ScenePresence> result = new List<ScenePresence>(); | 675 | List<ScenePresence> result = new List<ScenePresence>(); |
676 | 676 | ||
677 | foreach (ScenePresence avatar in Avatars.Values) | 677 | foreach (ScenePresence avatar in Avatars.Values) |
678 | { | 678 | { |
679 | result.Add(avatar); | 679 | result.Add(avatar); |
680 | } | 680 | } |
681 | 681 | ||
682 | return result; | 682 | return result; |
683 | } | 683 | } |
684 | 684 | ||
685 | /// <summary> | 685 | /// <summary> |
686 | /// Request a filtered list of Avatars in this World | 686 | /// Request a filtered list of Avatars in this World |
687 | /// </summary> | 687 | /// </summary> |
688 | /// <returns></returns> | 688 | /// <returns></returns> |
689 | public List<ScenePresence> RequestAvatarList(FilterAvatarList filter) | 689 | public List<ScenePresence> RequestAvatarList(FilterAvatarList filter) |
690 | { | 690 | { |
691 | List<ScenePresence> result = new List<ScenePresence>(); | 691 | List<ScenePresence> result = new List<ScenePresence>(); |
692 | 692 | ||
693 | foreach (ScenePresence avatar in Avatars.Values) | 693 | foreach (ScenePresence avatar in Avatars.Values) |
694 | { | 694 | { |
695 | if (filter(avatar)) | 695 | if (filter(avatar)) |
696 | { | 696 | { |
697 | result.Add(avatar); | 697 | result.Add(avatar); |
698 | } | 698 | } |
699 | } | 699 | } |
700 | 700 | ||
701 | return result; | 701 | return result; |
702 | } | 702 | } |
703 | 703 | ||
704 | /// <summary> | 704 | /// <summary> |
705 | /// Request a Avatar by UUID | 705 | /// Request a Avatar by UUID |
706 | /// </summary> | 706 | /// </summary> |
707 | /// <param name="avatarID"></param> | 707 | /// <param name="avatarID"></param> |
708 | /// <returns></returns> | 708 | /// <returns></returns> |
709 | public ScenePresence RequestAvatar(LLUUID avatarID) | 709 | public ScenePresence RequestAvatar(LLUUID avatarID) |
710 | { | 710 | { |
711 | if (this.Avatars.ContainsKey(avatarID)) | 711 | if (this.Avatars.ContainsKey(avatarID)) |
712 | { | 712 | { |
713 | return Avatars[avatarID]; | 713 | return Avatars[avatarID]; |
714 | } | 714 | } |
715 | return null; | 715 | return null; |
716 | } | 716 | } |
717 | 717 | ||
718 | public void ForEachScenePresence(ForEachScenePresenceDelegate whatToDo) | 718 | public void ForEachScenePresence(ForEachScenePresenceDelegate whatToDo) |
719 | { | 719 | { |
720 | foreach (ScenePresence presence in this.Avatars.Values) | 720 | foreach (ScenePresence presence in this.Avatars.Values) |
721 | { | 721 | { |
722 | whatToDo(presence); | 722 | whatToDo(presence); |
723 | } | 723 | } |
724 | } | 724 | } |
725 | #endregion | 725 | #endregion |
726 | 726 | ||
727 | 727 | ||
728 | /// <summary> | 728 | /// <summary> |
729 | /// | 729 | /// |
730 | /// </summary> | 730 | /// </summary> |
731 | /// <param name="entID"></param> | 731 | /// <param name="entID"></param> |
732 | /// <returns></returns> | 732 | /// <returns></returns> |
733 | public bool DeleteEntity(LLUUID entID) | 733 | public bool DeleteEntity(LLUUID entID) |
734 | { | 734 | { |
735 | if (this.Entities.ContainsKey(entID)) | 735 | if (this.Entities.ContainsKey(entID)) |
736 | { | 736 | { |
737 | this.Entities.Remove(entID); | 737 | this.Entities.Remove(entID); |
738 | return true; | 738 | return true; |
739 | } | 739 | } |
740 | return false; | 740 | return false; |
741 | } | 741 | } |
742 | 742 | ||
743 | public void SendAllSceneObjectsToClient(IClientAPI client) | 743 | public void SendAllSceneObjectsToClient(IClientAPI client) |
744 | { | 744 | { |
745 | foreach (EntityBase ent in Entities.Values) | 745 | foreach (EntityBase ent in Entities.Values) |
746 | { | 746 | { |
747 | if (ent is SceneObject) | 747 | if (ent is SceneObject) |
748 | { | 748 | { |
749 | ((SceneObject)ent).SendAllChildPrimsToClient(client); | 749 | ((SceneObject)ent).SendAllChildPrimsToClient(client); |
750 | } | 750 | } |
751 | } | 751 | } |
752 | } | 752 | } |
753 | 753 | ||
754 | #region RegionCommsHost | 754 | #region RegionCommsHost |
755 | 755 | ||
756 | /// <summary> | 756 | /// <summary> |
757 | /// | 757 | /// |
758 | /// </summary> | 758 | /// </summary> |
759 | public void RegisterRegionWithComms() | 759 | public void RegisterRegionWithComms() |
760 | { | 760 | { |
761 | 761 | ||
762 | this.regionCommsHost = this.commsManager.GridServer.RegisterRegion(this.m_regInfo); | 762 | this.regionCommsHost = this.commsManager.GridServer.RegisterRegion(this.m_regInfo); |
763 | if (this.regionCommsHost != null) | 763 | if (this.regionCommsHost != null) |
764 | { | 764 | { |
765 | this.regionCommsHost.OnExpectUser += this.NewUserConnection; | 765 | this.regionCommsHost.OnExpectUser += this.NewUserConnection; |
766 | this.regionCommsHost.OnAvatarCrossingIntoRegion += this.AgentCrossing; | 766 | this.regionCommsHost.OnAvatarCrossingIntoRegion += this.AgentCrossing; |
767 | } | 767 | } |
768 | } | 768 | } |
769 | 769 | ||
770 | /// <summary> | 770 | /// <summary> |
771 | /// | 771 | /// |
772 | /// </summary> | 772 | /// </summary> |
773 | /// <param name="regionHandle"></param> | 773 | /// <param name="regionHandle"></param> |
774 | /// <param name="agent"></param> | 774 | /// <param name="agent"></param> |
775 | public void NewUserConnection(ulong regionHandle, AgentCircuitData agent) | 775 | public void NewUserConnection(ulong regionHandle, AgentCircuitData agent) |
776 | { | 776 | { |
777 | // Console.WriteLine("World.cs - add new user connection"); | 777 | // Console.WriteLine("World.cs - add new user connection"); |
778 | //should just check that its meant for this region | 778 | //should just check that its meant for this region |
779 | if (regionHandle == this.m_regInfo.RegionHandle) | 779 | if (regionHandle == this.m_regInfo.RegionHandle) |
780 | { | 780 | { |
781 | if (agent.CapsPath != "") | 781 | if (agent.CapsPath != "") |
782 | { | 782 | { |
783 | //Console.WriteLine("new user, so creating caps handler for it"); | 783 | //Console.WriteLine("new user, so creating caps handler for it"); |
784 | Caps cap = new Caps(this.assetCache, httpListener, this.m_regInfo.ExternalHostName, this.m_regInfo.ExternalEndPoint.Port, agent.CapsPath, agent.AgentID); | 784 | Caps cap = new Caps(this.assetCache, httpListener, this.m_regInfo.ExternalHostName, this.m_regInfo.ExternalEndPoint.Port, agent.CapsPath, agent.AgentID); |
785 | cap.RegisterHandlers(); | 785 | cap.RegisterHandlers(); |
786 | if (capsHandlers.ContainsKey(agent.AgentID)) | 786 | if (capsHandlers.ContainsKey(agent.AgentID)) |
787 | { | 787 | { |
788 | OpenSim.Framework.Console.MainLog.Instance.Warn("Adding duplicate CAPS entry for user " + agent.AgentID.ToStringHyphenated()); | 788 | OpenSim.Framework.Console.MainLog.Instance.Warn("Adding duplicate CAPS entry for user " + agent.AgentID.ToStringHyphenated()); |
789 | this.capsHandlers[agent.AgentID] = cap; | 789 | this.capsHandlers[agent.AgentID] = cap; |
790 | } | 790 | } |
791 | else | 791 | else |
792 | { | 792 | { |
793 | this.capsHandlers.Add(agent.AgentID, cap); | 793 | this.capsHandlers.Add(agent.AgentID, cap); |
794 | } | 794 | } |
795 | 795 | ||
796 | } | 796 | } |
797 | this.authenticateHandler.AddNewCircuit(agent.circuitcode, agent); | 797 | this.authenticateHandler.AddNewCircuit(agent.circuitcode, agent); |
798 | } | 798 | } |
799 | } | 799 | } |
800 | 800 | ||
801 | public void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position) | 801 | public void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position) |
802 | { | 802 | { |
803 | if (regionHandle == this.m_regInfo.RegionHandle) | 803 | if (regionHandle == this.m_regInfo.RegionHandle) |
804 | { | 804 | { |
805 | if (this.Avatars.ContainsKey(agentID)) | 805 | if (this.Avatars.ContainsKey(agentID)) |
806 | { | 806 | { |
807 | this.Avatars[agentID].MakeAvatar(position); | 807 | this.Avatars[agentID].MakeAvatar(position); |
808 | } | 808 | } |
809 | } | 809 | } |
810 | } | 810 | } |
811 | 811 | ||
812 | /// <summary> | 812 | /// <summary> |
813 | /// | 813 | /// |
814 | /// </summary> | 814 | /// </summary> |
815 | public void InformClientOfNeighbours(IClientAPI remoteClient) | 815 | public void InformClientOfNeighbours(IClientAPI remoteClient) |
816 | { | 816 | { |
817 | List<RegionInfo> neighbours = this.commsManager.GridServer.RequestNeighbours(this.m_regInfo); | 817 | List<RegionInfo> neighbours = this.commsManager.GridServer.RequestNeighbours(this.m_regInfo); |
818 | 818 | ||
819 | if (neighbours != null) | 819 | if (neighbours != null) |
820 | { | 820 | { |
821 | for (int i = 0; i < neighbours.Count; i++) | 821 | for (int i = 0; i < neighbours.Count; i++) |
822 | { | 822 | { |
823 | AgentCircuitData agent = remoteClient.RequestClientInfo(); | 823 | AgentCircuitData agent = remoteClient.RequestClientInfo(); |
824 | agent.BaseFolder = LLUUID.Zero; | 824 | agent.BaseFolder = LLUUID.Zero; |
825 | agent.InventoryFolder = LLUUID.Zero; | 825 | agent.InventoryFolder = LLUUID.Zero; |
826 | agent.startpos = new LLVector3(128, 128, 70); | 826 | agent.startpos = new LLVector3(128, 128, 70); |
827 | agent.child = true; | 827 | agent.child = true; |
828 | this.commsManager.InterRegion.InformRegionOfChildAgent(neighbours[i].RegionHandle, agent); | 828 | this.commsManager.InterRegion.InformRegionOfChildAgent(neighbours[i].RegionHandle, agent); |
829 | remoteClient.InformClientOfNeighbour(neighbours[i].RegionHandle, neighbours[i].ExternalEndPoint); | 829 | remoteClient.InformClientOfNeighbour(neighbours[i].RegionHandle, neighbours[i].ExternalEndPoint); |
830 | //this.capsHandlers[remoteClient.AgentId].CreateEstablishAgentComms("", System.Net.IPAddress.Parse(neighbours[i].CommsIPListenAddr) + ":" + neighbours[i].CommsIPListenPort); | 830 | //this.capsHandlers[remoteClient.AgentId].CreateEstablishAgentComms("", System.Net.IPAddress.Parse(neighbours[i].CommsIPListenAddr) + ":" + neighbours[i].CommsIPListenPort); |
831 | } | 831 | } |
832 | } | 832 | } |
833 | } | 833 | } |
834 | 834 | ||
835 | /// <summary> | 835 | /// <summary> |
836 | /// | 836 | /// |
837 | /// </summary> | 837 | /// </summary> |
838 | /// <param name="regionHandle"></param> | 838 | /// <param name="regionHandle"></param> |
839 | /// <returns></returns> | 839 | /// <returns></returns> |
840 | public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle) | 840 | public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle) |
841 | { | 841 | { |
842 | return this.commsManager.GridServer.RequestNeighbourInfo(regionHandle); | 842 | return this.commsManager.GridServer.RequestNeighbourInfo(regionHandle); |
843 | } | 843 | } |
844 | 844 | ||
845 | /// <summary> | 845 | /// <summary> |
846 | /// | 846 | /// |
847 | /// </summary> | 847 | /// </summary> |
848 | /// <param name="minX"></param> | 848 | /// <param name="minX"></param> |
849 | /// <param name="minY"></param> | 849 | /// <param name="minY"></param> |
850 | /// <param name="maxX"></param> | 850 | /// <param name="maxX"></param> |
851 | /// <param name="maxY"></param> | 851 | /// <param name="maxY"></param> |
852 | public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY) | 852 | public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY) |
853 | { | 853 | { |
854 | List<MapBlockData> mapBlocks; | 854 | List<MapBlockData> mapBlocks; |
855 | mapBlocks = this.commsManager.GridServer.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); | 855 | mapBlocks = this.commsManager.GridServer.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); |
856 | remoteClient.SendMapBlock(mapBlocks); | 856 | remoteClient.SendMapBlock(mapBlocks); |
857 | } | 857 | } |
858 | 858 | ||
859 | /// <summary> | 859 | /// <summary> |
860 | /// | 860 | /// |
861 | /// </summary> | 861 | /// </summary> |
862 | /// <param name="remoteClient"></param> | 862 | /// <param name="remoteClient"></param> |
863 | /// <param name="RegionHandle"></param> | 863 | /// <param name="RegionHandle"></param> |
864 | /// <param name="position"></param> | 864 | /// <param name="position"></param> |
865 | /// <param name="lookAt"></param> | 865 | /// <param name="lookAt"></param> |
866 | /// <param name="flags"></param> | 866 | /// <param name="flags"></param> |
867 | public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags) | 867 | public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags) |
868 | { | 868 | { |
869 | if (regionHandle == this.m_regionHandle) | 869 | if (regionHandle == this.m_regionHandle) |
870 | { | 870 | { |
871 | if (this.Avatars.ContainsKey(remoteClient.AgentId)) | 871 | if (this.Avatars.ContainsKey(remoteClient.AgentId)) |
872 | { | 872 | { |
873 | remoteClient.SendTeleportLocationStart(); | 873 | remoteClient.SendTeleportLocationStart(); |
874 | remoteClient.SendLocalTeleport(position, lookAt, flags); | 874 | remoteClient.SendLocalTeleport(position, lookAt, flags); |
875 | this.Avatars[remoteClient.AgentId].Teleport(position); | 875 | this.Avatars[remoteClient.AgentId].Teleport(position); |
876 | } | 876 | } |
877 | } | 877 | } |
878 | else | 878 | else |
879 | { | 879 | { |
880 | RegionInfo reg = this.RequestNeighbouringRegionInfo(regionHandle); | 880 | RegionInfo reg = this.RequestNeighbouringRegionInfo(regionHandle); |
881 | if (reg != null) | 881 | if (reg != null) |
882 | { | 882 | { |
883 | remoteClient.SendTeleportLocationStart(); | 883 | remoteClient.SendTeleportLocationStart(); |
884 | AgentCircuitData agent = remoteClient.RequestClientInfo(); | 884 | AgentCircuitData agent = remoteClient.RequestClientInfo(); |
885 | agent.BaseFolder = LLUUID.Zero; | 885 | agent.BaseFolder = LLUUID.Zero; |
886 | agent.InventoryFolder = LLUUID.Zero; | 886 | agent.InventoryFolder = LLUUID.Zero; |
887 | agent.startpos = new LLVector3(128, 128, 70); | 887 | agent.startpos = new LLVector3(128, 128, 70); |
888 | agent.child = true; | 888 | agent.child = true; |
889 | this.commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent); | 889 | this.commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent); |
890 | this.commsManager.InterRegion.ExpectAvatarCrossing(regionHandle, remoteClient.AgentId, position); | 890 | this.commsManager.InterRegion.ExpectAvatarCrossing(regionHandle, remoteClient.AgentId, position); |
891 | 891 | ||
892 | remoteClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4)); | 892 | remoteClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4)); |
893 | 893 | ||
894 | } | 894 | } |
895 | } | 895 | } |
896 | } | 896 | } |
897 | 897 | ||
898 | /// <summary> | 898 | /// <summary> |
899 | /// | 899 | /// |
900 | /// </summary> | 900 | /// </summary> |
901 | /// <param name="regionhandle"></param> | 901 | /// <param name="regionhandle"></param> |
902 | /// <param name="agentID"></param> | 902 | /// <param name="agentID"></param> |
903 | /// <param name="position"></param> | 903 | /// <param name="position"></param> |
904 | public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position) | 904 | public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position) |
905 | { | 905 | { |
906 | return this.commsManager.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position); | 906 | return this.commsManager.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position); |
907 | } | 907 | } |
908 | 908 | ||
909 | public void performParcelPrimCountUpdate() | 909 | public void performParcelPrimCountUpdate() |
910 | { | 910 | { |
911 | m_parcelManager.resetAllParcelPrimCounts(); | 911 | m_parcelManager.resetAllParcelPrimCounts(); |
912 | m_eventManager.TriggerParcelPrimCountUpdate(); | 912 | m_eventManager.TriggerParcelPrimCountUpdate(); |
913 | m_parcelManager.finalizeParcelPrimCountUpdate(); | 913 | m_parcelManager.finalizeParcelPrimCountUpdate(); |
914 | m_parcelManager.parcelPrimCountTainted = false; | 914 | m_parcelManager.parcelPrimCountTainted = false; |
915 | } | 915 | } |
916 | #endregion | 916 | #endregion |
917 | 917 | ||
918 | } | 918 | } |
919 | } | 919 | } |
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index 161a5cf..cbf69ac 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs | |||
@@ -1,195 +1,195 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using libsecondlife; | 31 | using libsecondlife; |
32 | using OpenSim.Framework.Console; | 32 | using OpenSim.Framework.Console; |
33 | using OpenSim.Framework.Interfaces; | 33 | using OpenSim.Framework.Interfaces; |
34 | using OpenSim.Framework.Types; | 34 | using OpenSim.Framework.Types; |
35 | using OpenSim.Region.Caches; | 35 | using OpenSim.Region.Caches; |
36 | using OpenSim.Region.Terrain; | 36 | using OpenSim.Region.Terrain; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | 38 | ||
39 | namespace OpenSim.Region.Environment.Scenes | 39 | namespace OpenSim.Region.Environment.Scenes |
40 | { | 40 | { |
41 | public abstract class SceneBase : IWorld | 41 | public abstract class SceneBase : IWorld |
42 | { | 42 | { |
43 | public Dictionary<LLUUID, EntityBase> Entities; | 43 | public Dictionary<LLUUID, EntityBase> Entities; |
44 | protected ulong m_regionHandle; | 44 | protected ulong m_regionHandle; |
45 | protected string m_regionName; | 45 | protected string m_regionName; |
46 | protected RegionInfo m_regInfo; | 46 | protected RegionInfo m_regInfo; |
47 | 47 | ||
48 | public TerrainEngine Terrain; | 48 | public TerrainEngine Terrain; |
49 | 49 | ||
50 | public string m_datastore; | 50 | public string m_datastore; |
51 | public ILocalStorage localStorage; | 51 | public ILocalStorage localStorage; |
52 | 52 | ||
53 | protected object m_syncRoot = new object(); | 53 | protected object m_syncRoot = new object(); |
54 | private uint m_nextLocalId = 8880000; | 54 | private uint m_nextLocalId = 8880000; |
55 | protected AssetCache assetCache; | 55 | protected AssetCache assetCache; |
56 | 56 | ||
57 | #region Update Methods | 57 | #region Update Methods |
58 | /// <summary> | 58 | /// <summary> |
59 | /// Normally called once every frame/tick to let the world preform anything required (like running the physics simulation) | 59 | /// Normally called once every frame/tick to let the world preform anything required (like running the physics simulation) |
60 | /// </summary> | 60 | /// </summary> |
61 | public abstract void Update(); | 61 | public abstract void Update(); |
62 | 62 | ||
63 | #endregion | 63 | #endregion |
64 | 64 | ||
65 | #region Terrain Methods | 65 | #region Terrain Methods |
66 | 66 | ||
67 | /// <summary> | 67 | /// <summary> |
68 | /// Loads the World heightmap | 68 | /// Loads the World heightmap |
69 | /// </summary> | 69 | /// </summary> |
70 | public abstract void LoadWorldMap(); | 70 | public abstract void LoadWorldMap(); |
71 | 71 | ||
72 | /// <summary> | 72 | /// <summary> |
73 | /// Loads a new storage subsystem from a named library | 73 | /// Loads a new storage subsystem from a named library |
74 | /// </summary> | 74 | /// </summary> |
75 | /// <param name="dllName">Storage Library</param> | 75 | /// <param name="dllName">Storage Library</param> |
76 | /// <returns>Successful or not</returns> | 76 | /// <returns>Successful or not</returns> |
77 | public bool LoadStorageDLL(string dllName) | 77 | public bool LoadStorageDLL(string dllName) |
78 | { | 78 | { |
79 | try | 79 | try |
80 | { | 80 | { |
81 | Assembly pluginAssembly = Assembly.LoadFrom(dllName); | 81 | Assembly pluginAssembly = Assembly.LoadFrom(dllName); |
82 | ILocalStorage store = null; | 82 | ILocalStorage store = null; |
83 | 83 | ||
84 | foreach (Type pluginType in pluginAssembly.GetTypes()) | 84 | foreach (Type pluginType in pluginAssembly.GetTypes()) |
85 | { | 85 | { |
86 | if (pluginType.IsPublic) | 86 | if (pluginType.IsPublic) |
87 | { | 87 | { |
88 | if (!pluginType.IsAbstract) | 88 | if (!pluginType.IsAbstract) |
89 | { | 89 | { |
90 | Type typeInterface = pluginType.GetInterface("ILocalStorage", true); | 90 | Type typeInterface = pluginType.GetInterface("ILocalStorage", true); |
91 | 91 | ||
92 | if (typeInterface != null) | 92 | if (typeInterface != null) |
93 | { | 93 | { |
94 | ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | 94 | ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); |
95 | store = plug; | 95 | store = plug; |
96 | 96 | ||
97 | store.Initialise(this.m_datastore); | 97 | store.Initialise(this.m_datastore); |
98 | break; | 98 | break; |
99 | } | 99 | } |
100 | 100 | ||
101 | typeInterface = null; | 101 | typeInterface = null; |
102 | } | 102 | } |
103 | } | 103 | } |
104 | } | 104 | } |
105 | pluginAssembly = null; | 105 | pluginAssembly = null; |
106 | this.localStorage = store; | 106 | this.localStorage = store; |
107 | return (store == null); | 107 | return (store == null); |
108 | } | 108 | } |
109 | catch (Exception e) | 109 | catch (Exception e) |
110 | { | 110 | { |
111 | MainLog.Instance.Warn("World.cs: LoadStorageDLL() - Failed with exception " + e.ToString()); | 111 | MainLog.Instance.Warn("World.cs: LoadStorageDLL() - Failed with exception " + e.ToString()); |
112 | return false; | 112 | return false; |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | 116 | ||
117 | /// <summary> | 117 | /// <summary> |
118 | /// Send the region heightmap to the client | 118 | /// Send the region heightmap to the client |
119 | /// </summary> | 119 | /// </summary> |
120 | /// <param name="RemoteClient">Client to send to</param> | 120 | /// <param name="RemoteClient">Client to send to</param> |
121 | public virtual void SendLayerData(IClientAPI RemoteClient) | 121 | public virtual void SendLayerData(IClientAPI RemoteClient) |
122 | { | 122 | { |
123 | RemoteClient.SendLayerData(Terrain.getHeights1D()); | 123 | RemoteClient.SendLayerData(Terrain.getHeights1D()); |
124 | } | 124 | } |
125 | 125 | ||
126 | /// <summary> | 126 | /// <summary> |
127 | /// Sends a specified patch to a client | 127 | /// Sends a specified patch to a client |
128 | /// </summary> | 128 | /// </summary> |
129 | /// <param name="px">Patch coordinate (x) 0..16</param> | 129 | /// <param name="px">Patch coordinate (x) 0..16</param> |
130 | /// <param name="py">Patch coordinate (y) 0..16</param> | 130 | /// <param name="py">Patch coordinate (y) 0..16</param> |
131 | /// <param name="RemoteClient">The client to send to</param> | 131 | /// <param name="RemoteClient">The client to send to</param> |
132 | public virtual void SendLayerData(int px, int py, IClientAPI RemoteClient) | 132 | public virtual void SendLayerData(int px, int py, IClientAPI RemoteClient) |
133 | { | 133 | { |
134 | RemoteClient.SendLayerData(px, py, Terrain.getHeights1D()); | 134 | RemoteClient.SendLayerData(px, py, Terrain.getHeights1D()); |
135 | } | 135 | } |
136 | 136 | ||
137 | #endregion | 137 | #endregion |
138 | 138 | ||
139 | #region Add/Remove Agent/Avatar | 139 | #region Add/Remove Agent/Avatar |
140 | /// <summary> | 140 | /// <summary> |
141 | /// | 141 | /// |
142 | /// </summary> | 142 | /// </summary> |
143 | /// <param name="remoteClient"></param> | 143 | /// <param name="remoteClient"></param> |
144 | /// <param name="agentID"></param> | 144 | /// <param name="agentID"></param> |
145 | /// <param name="child"></param> | 145 | /// <param name="child"></param> |
146 | public abstract void AddNewClient(IClientAPI client, bool child); | 146 | public abstract void AddNewClient(IClientAPI client, bool child); |
147 | 147 | ||
148 | /// <summary> | 148 | /// <summary> |
149 | /// | 149 | /// |
150 | /// </summary> | 150 | /// </summary> |
151 | /// <param name="agentID"></param> | 151 | /// <param name="agentID"></param> |
152 | public abstract void RemoveClient(LLUUID agentID); | 152 | public abstract void RemoveClient(LLUUID agentID); |
153 | 153 | ||
154 | #endregion | 154 | #endregion |
155 | 155 | ||
156 | /// <summary> | 156 | /// <summary> |
157 | /// | 157 | /// |
158 | /// </summary> | 158 | /// </summary> |
159 | /// <returns></returns> | 159 | /// <returns></returns> |
160 | public virtual RegionInfo RegionInfo | 160 | public virtual RegionInfo RegionInfo |
161 | { | 161 | { |
162 | get { return this.m_regInfo; } | 162 | get { return this.m_regInfo; } |
163 | } | 163 | } |
164 | 164 | ||
165 | public object SyncRoot | 165 | public object SyncRoot |
166 | { | 166 | { |
167 | get { return m_syncRoot; } | 167 | get { return m_syncRoot; } |
168 | } | 168 | } |
169 | 169 | ||
170 | public uint NextLocalId | 170 | public uint NextLocalId |
171 | { | 171 | { |
172 | get { return m_nextLocalId++; } | 172 | get { return m_nextLocalId++; } |
173 | } | 173 | } |
174 | 174 | ||
175 | #region Shutdown | 175 | #region Shutdown |
176 | /// <summary> | 176 | /// <summary> |
177 | /// Tidy before shutdown | 177 | /// Tidy before shutdown |
178 | /// </summary> | 178 | /// </summary> |
179 | public virtual void Close() | 179 | public virtual void Close() |
180 | { | 180 | { |
181 | try | 181 | try |
182 | { | 182 | { |
183 | this.localStorage.ShutDown(); | 183 | this.localStorage.ShutDown(); |
184 | } | 184 | } |
185 | catch (Exception e) | 185 | catch (Exception e) |
186 | { | 186 | { |
187 | MainLog.Instance.WriteLine(LogPriority.HIGH, "World.cs: Close() - Failed with exception " + e.ToString()); | 187 | MainLog.Instance.WriteLine(LogPriority.HIGH, "World.cs: Close() - Failed with exception " + e.ToString()); |
188 | } | 188 | } |
189 | } | 189 | } |
190 | 190 | ||
191 | #endregion | 191 | #endregion |
192 | 192 | ||
193 | 193 | ||
194 | } | 194 | } |
195 | } | 195 | } |
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index 1e4b163..255cbf2 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs | |||
@@ -1,82 +1,82 @@ | |||
1 | using libsecondlife; | 1 | using libsecondlife; |
2 | 2 | ||
3 | namespace OpenSim.Region.Environment.Scenes | 3 | namespace OpenSim.Region.Environment.Scenes |
4 | { | 4 | { |
5 | /// <summary> | 5 | /// <summary> |
6 | /// A class for triggering remote scene events. | 6 | /// A class for triggering remote scene events. |
7 | /// </summary> | 7 | /// </summary> |
8 | public class EventManager | 8 | public class EventManager |
9 | { | 9 | { |
10 | public delegate void OnFrameDelegate(); | 10 | public delegate void OnFrameDelegate(); |
11 | public event OnFrameDelegate OnFrame; | 11 | public event OnFrameDelegate OnFrame; |
12 | 12 | ||
13 | public delegate void OnBackupDelegate(Interfaces.IRegionDataStore datastore); | 13 | public delegate void OnBackupDelegate(Interfaces.IRegionDataStore datastore); |
14 | public event OnBackupDelegate OnBackup; | 14 | public event OnBackupDelegate OnBackup; |
15 | 15 | ||
16 | public delegate void OnNewPresenceDelegate(ScenePresence presence); | 16 | public delegate void OnNewPresenceDelegate(ScenePresence presence); |
17 | public event OnNewPresenceDelegate OnNewPresence; | 17 | public event OnNewPresenceDelegate OnNewPresence; |
18 | 18 | ||
19 | public delegate void OnRemovePresenceDelegate(LLUUID uuid); | 19 | public delegate void OnRemovePresenceDelegate(LLUUID uuid); |
20 | public event OnRemovePresenceDelegate OnRemovePresence; | 20 | public event OnRemovePresenceDelegate OnRemovePresence; |
21 | 21 | ||
22 | public delegate void OnParcelPrimCountUpdateDelegate(); | 22 | public delegate void OnParcelPrimCountUpdateDelegate(); |
23 | public event OnParcelPrimCountUpdateDelegate OnParcelPrimCountUpdate; | 23 | public event OnParcelPrimCountUpdateDelegate OnParcelPrimCountUpdate; |
24 | 24 | ||
25 | public delegate void OnParcelPrimCountAddDelegate(SceneObject obj); | 25 | public delegate void OnParcelPrimCountAddDelegate(SceneObject obj); |
26 | public event OnParcelPrimCountAddDelegate OnParcelPrimCountAdd; | 26 | public event OnParcelPrimCountAddDelegate OnParcelPrimCountAdd; |
27 | 27 | ||
28 | public delegate void OnScriptConsoleDelegate(string[] args); | 28 | public delegate void OnScriptConsoleDelegate(string[] args); |
29 | public event OnScriptConsoleDelegate OnScriptConsole; | 29 | public event OnScriptConsoleDelegate OnScriptConsole; |
30 | 30 | ||
31 | public void TriggerOnScriptConsole(string[] args) | 31 | public void TriggerOnScriptConsole(string[] args) |
32 | { | 32 | { |
33 | if (OnScriptConsole != null) | 33 | if (OnScriptConsole != null) |
34 | OnScriptConsole(args); | 34 | OnScriptConsole(args); |
35 | } | 35 | } |
36 | 36 | ||
37 | public void TriggerOnFrame() | 37 | public void TriggerOnFrame() |
38 | { | 38 | { |
39 | if (OnFrame != null) | 39 | if (OnFrame != null) |
40 | { | 40 | { |
41 | OnFrame(); | 41 | OnFrame(); |
42 | } | 42 | } |
43 | } | 43 | } |
44 | 44 | ||
45 | public void TriggerOnNewPresence(ScenePresence presence) | 45 | public void TriggerOnNewPresence(ScenePresence presence) |
46 | { | 46 | { |
47 | if (OnNewPresence != null) | 47 | if (OnNewPresence != null) |
48 | OnNewPresence(presence); | 48 | OnNewPresence(presence); |
49 | } | 49 | } |
50 | 50 | ||
51 | public void TriggerOnRemovePresence(LLUUID uuid) | 51 | public void TriggerOnRemovePresence(LLUUID uuid) |
52 | { | 52 | { |
53 | if (OnRemovePresence != null) | 53 | if (OnRemovePresence != null) |
54 | { | 54 | { |
55 | OnRemovePresence(uuid); | 55 | OnRemovePresence(uuid); |
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | ||
59 | public void TriggerOnBackup(Interfaces.IRegionDataStore dstore) | 59 | public void TriggerOnBackup(Interfaces.IRegionDataStore dstore) |
60 | { | 60 | { |
61 | if (OnBackup != null) | 61 | if (OnBackup != null) |
62 | { | 62 | { |
63 | OnBackup(dstore); | 63 | OnBackup(dstore); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | public void TriggerParcelPrimCountUpdate() | 67 | public void TriggerParcelPrimCountUpdate() |
68 | { | 68 | { |
69 | if (OnParcelPrimCountUpdate != null) | 69 | if (OnParcelPrimCountUpdate != null) |
70 | { | 70 | { |
71 | OnParcelPrimCountUpdate(); | 71 | OnParcelPrimCountUpdate(); |
72 | } | 72 | } |
73 | } | 73 | } |
74 | public void TriggerParcelPrimCountAdd(SceneObject obj) | 74 | public void TriggerParcelPrimCountAdd(SceneObject obj) |
75 | { | 75 | { |
76 | if (OnParcelPrimCountAdd != null) | 76 | if (OnParcelPrimCountAdd != null) |
77 | { | 77 | { |
78 | OnParcelPrimCountAdd(obj); | 78 | OnParcelPrimCountAdd(obj); |
79 | } | 79 | } |
80 | } | 80 | } |
81 | } | 81 | } |
82 | } | 82 | } |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObject.cs b/OpenSim/Region/Environment/Scenes/SceneObject.cs index e615599..43d41e6 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObject.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObject.cs | |||
@@ -1,309 +1,309 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Text; | 29 | using System.Text; |
30 | using libsecondlife; | 30 | using libsecondlife; |
31 | using libsecondlife.Packets; | 31 | using libsecondlife.Packets; |
32 | using OpenSim.Framework.Interfaces; | 32 | using OpenSim.Framework.Interfaces; |
33 | using OpenSim.Framework.Types; | 33 | using OpenSim.Framework.Types; |
34 | using OpenSim.Physics.Manager; | 34 | using OpenSim.Physics.Manager; |
35 | 35 | ||
36 | namespace OpenSim.Region.Environment.Scenes | 36 | namespace OpenSim.Region.Environment.Scenes |
37 | { | 37 | { |
38 | public class SceneObject : EntityBase | 38 | public class SceneObject : EntityBase |
39 | { | 39 | { |
40 | private Encoding enc = Encoding.ASCII; | 40 | private Encoding enc = Encoding.ASCII; |
41 | private Dictionary<LLUUID, Primitive> ChildPrimitives = new Dictionary<LLUUID, Primitive>(); //list of all primitive id's that are part of this group | 41 | private Dictionary<LLUUID, Primitive> ChildPrimitives = new Dictionary<LLUUID, Primitive>(); //list of all primitive id's that are part of this group |
42 | public Primitive rootPrimitive; | 42 | public Primitive rootPrimitive; |
43 | private new Scene m_world; | 43 | private new Scene m_world; |
44 | protected ulong m_regionHandle; | 44 | protected ulong m_regionHandle; |
45 | 45 | ||
46 | private bool physicsEnabled = false; | 46 | private bool physicsEnabled = false; |
47 | private PhysicsScene m_PhysScene; | 47 | private PhysicsScene m_PhysScene; |
48 | private PhysicsActor m_PhysActor; | 48 | private PhysicsActor m_PhysActor; |
49 | 49 | ||
50 | private EventManager m_eventManager; | 50 | private EventManager m_eventManager; |
51 | 51 | ||
52 | public bool isSelected = false; | 52 | public bool isSelected = false; |
53 | 53 | ||
54 | public LLUUID rootUUID | 54 | public LLUUID rootUUID |
55 | { | 55 | { |
56 | get | 56 | get |
57 | { | 57 | { |
58 | this.uuid = this.rootPrimitive.uuid; | 58 | this.uuid = this.rootPrimitive.uuid; |
59 | return this.uuid; | 59 | return this.uuid; |
60 | } | 60 | } |
61 | } | 61 | } |
62 | 62 | ||
63 | public uint rootLocalID | 63 | public uint rootLocalID |
64 | { | 64 | { |
65 | get | 65 | get |
66 | { | 66 | { |
67 | this.m_localId = this.rootPrimitive.LocalId; | 67 | this.m_localId = this.rootPrimitive.LocalId; |
68 | return this.LocalId; | 68 | return this.LocalId; |
69 | } | 69 | } |
70 | } | 70 | } |
71 | 71 | ||
72 | public int primCount | 72 | public int primCount |
73 | { | 73 | { |
74 | get | 74 | get |
75 | { | 75 | { |
76 | return this.ChildPrimitives.Count; | 76 | return this.ChildPrimitives.Count; |
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
80 | public Dictionary<LLUUID, Primitive> Children | 80 | public Dictionary<LLUUID, Primitive> Children |
81 | { | 81 | { |
82 | get | 82 | get |
83 | { | 83 | { |
84 | return this.ChildPrimitives; | 84 | return this.ChildPrimitives; |
85 | } | 85 | } |
86 | } | 86 | } |
87 | 87 | ||
88 | /// <summary> | 88 | /// <summary> |
89 | /// | 89 | /// |
90 | /// </summary> | 90 | /// </summary> |
91 | public SceneObject(Scene world, EventManager eventManager, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) | 91 | public SceneObject(Scene world, EventManager eventManager, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) |
92 | { | 92 | { |
93 | m_regionHandle = world.RegionInfo.RegionHandle; | 93 | m_regionHandle = world.RegionInfo.RegionHandle; |
94 | m_world = world; | 94 | m_world = world; |
95 | m_eventManager = eventManager; | 95 | m_eventManager = eventManager; |
96 | 96 | ||
97 | this.Pos = pos; | 97 | this.Pos = pos; |
98 | this.CreateRootFromShape(ownerID, localID, shape, pos); | 98 | this.CreateRootFromShape(ownerID, localID, shape, pos); |
99 | 99 | ||
100 | registerEvents(); | 100 | registerEvents(); |
101 | 101 | ||
102 | } | 102 | } |
103 | 103 | ||
104 | /// <summary> | 104 | /// <summary> |
105 | /// | 105 | /// |
106 | /// </summary> | 106 | /// </summary> |
107 | /// <remarks>Need a null constructor for duplication</remarks> | 107 | /// <remarks>Need a null constructor for duplication</remarks> |
108 | public SceneObject() | 108 | public SceneObject() |
109 | { | 109 | { |
110 | 110 | ||
111 | } | 111 | } |
112 | 112 | ||
113 | public void registerEvents() | 113 | public void registerEvents() |
114 | { | 114 | { |
115 | m_eventManager.OnBackup += new EventManager.OnBackupDelegate(ProcessBackup); | 115 | m_eventManager.OnBackup += new EventManager.OnBackupDelegate(ProcessBackup); |
116 | m_eventManager.OnParcelPrimCountUpdate += new EventManager.OnParcelPrimCountUpdateDelegate(ProcessParcelPrimCountUpdate); | 116 | m_eventManager.OnParcelPrimCountUpdate += new EventManager.OnParcelPrimCountUpdateDelegate(ProcessParcelPrimCountUpdate); |
117 | } | 117 | } |
118 | 118 | ||
119 | public void unregisterEvents() | 119 | public void unregisterEvents() |
120 | { | 120 | { |
121 | m_eventManager.OnBackup -= new EventManager.OnBackupDelegate(ProcessBackup); | 121 | m_eventManager.OnBackup -= new EventManager.OnBackupDelegate(ProcessBackup); |
122 | m_eventManager.OnParcelPrimCountUpdate -= new EventManager.OnParcelPrimCountUpdateDelegate(ProcessParcelPrimCountUpdate); | 122 | m_eventManager.OnParcelPrimCountUpdate -= new EventManager.OnParcelPrimCountUpdateDelegate(ProcessParcelPrimCountUpdate); |
123 | } | 123 | } |
124 | 124 | ||
125 | /// <summary> | 125 | /// <summary> |
126 | /// Processes backup | 126 | /// Processes backup |
127 | /// </summary> | 127 | /// </summary> |
128 | /// <param name="datastore"></param> | 128 | /// <param name="datastore"></param> |
129 | public void ProcessBackup(OpenSim.Region.Interfaces.IRegionDataStore datastore) | 129 | public void ProcessBackup(OpenSim.Region.Interfaces.IRegionDataStore datastore) |
130 | { | 130 | { |
131 | datastore.StoreObject(this); | 131 | datastore.StoreObject(this); |
132 | } | 132 | } |
133 | 133 | ||
134 | /// <summary> | 134 | /// <summary> |
135 | /// Sends my primitive info to the parcel manager for it to keep tally of all of the prims! | 135 | /// Sends my primitive info to the parcel manager for it to keep tally of all of the prims! |
136 | /// </summary> | 136 | /// </summary> |
137 | private void ProcessParcelPrimCountUpdate() | 137 | private void ProcessParcelPrimCountUpdate() |
138 | { | 138 | { |
139 | 139 | ||
140 | m_eventManager.TriggerParcelPrimCountAdd(this); | 140 | m_eventManager.TriggerParcelPrimCountAdd(this); |
141 | } | 141 | } |
142 | 142 | ||
143 | /// <summary> | 143 | /// <summary> |
144 | /// | 144 | /// |
145 | /// </summary> | 145 | /// </summary> |
146 | /// <param name="addPacket"></param> | 146 | /// <param name="addPacket"></param> |
147 | /// <param name="agentID"></param> | 147 | /// <param name="agentID"></param> |
148 | /// <param name="localID"></param> | 148 | /// <param name="localID"></param> |
149 | public void CreateRootFromShape(LLUUID agentID, uint localID, PrimitiveBaseShape shape, LLVector3 pos) | 149 | public void CreateRootFromShape(LLUUID agentID, uint localID, PrimitiveBaseShape shape, LLVector3 pos) |
150 | { | 150 | { |
151 | 151 | ||
152 | this.rootPrimitive = new Primitive(this.m_regionHandle, this.m_world, agentID, localID, true, this, this, shape, pos); | 152 | this.rootPrimitive = new Primitive(this.m_regionHandle, this.m_world, agentID, localID, true, this, this, shape, pos); |
153 | 153 | ||
154 | this.children.Add(rootPrimitive); | 154 | this.children.Add(rootPrimitive); |
155 | this.ChildPrimitives.Add(this.rootUUID, this.rootPrimitive); | 155 | this.ChildPrimitives.Add(this.rootUUID, this.rootPrimitive); |
156 | } | 156 | } |
157 | 157 | ||
158 | /// <summary> | 158 | /// <summary> |
159 | /// | 159 | /// |
160 | /// </summary> | 160 | /// </summary> |
161 | /// <param name="data"></param> | 161 | /// <param name="data"></param> |
162 | public void CreateFromBytes(byte[] data) | 162 | public void CreateFromBytes(byte[] data) |
163 | { | 163 | { |
164 | 164 | ||
165 | } | 165 | } |
166 | 166 | ||
167 | /// <summary> | 167 | /// <summary> |
168 | /// Makes a copy of this SceneObject (and child primitives) | 168 | /// Makes a copy of this SceneObject (and child primitives) |
169 | /// </summary> | 169 | /// </summary> |
170 | /// <returns>A complete copy of the object</returns> | 170 | /// <returns>A complete copy of the object</returns> |
171 | public new SceneObject Copy() | 171 | public new SceneObject Copy() |
172 | { | 172 | { |
173 | SceneObject dupe = new SceneObject(); | 173 | SceneObject dupe = new SceneObject(); |
174 | 174 | ||
175 | dupe.m_world = this.m_world; | 175 | dupe.m_world = this.m_world; |
176 | dupe.m_eventManager = this.m_eventManager; | 176 | dupe.m_eventManager = this.m_eventManager; |
177 | dupe.m_regionHandle = this.m_regionHandle; | 177 | dupe.m_regionHandle = this.m_regionHandle; |
178 | Primitive newRoot = this.rootPrimitive.Copy(dupe, dupe); | 178 | Primitive newRoot = this.rootPrimitive.Copy(dupe, dupe); |
179 | dupe.rootPrimitive = newRoot; | 179 | dupe.rootPrimitive = newRoot; |
180 | dupe.children.Add(dupe.rootPrimitive); | 180 | dupe.children.Add(dupe.rootPrimitive); |
181 | dupe.rootPrimitive.Pos = this.Pos; | 181 | dupe.rootPrimitive.Pos = this.Pos; |
182 | dupe.Rotation = this.Rotation; | 182 | dupe.Rotation = this.Rotation; |
183 | dupe.LocalId = m_world.PrimIDAllocate(); | 183 | dupe.LocalId = m_world.PrimIDAllocate(); |
184 | 184 | ||
185 | dupe.registerEvents(); | 185 | dupe.registerEvents(); |
186 | return dupe; | 186 | return dupe; |
187 | } | 187 | } |
188 | 188 | ||
189 | /// <summary> | 189 | /// <summary> |
190 | /// | 190 | /// |
191 | /// </summary> | 191 | /// </summary> |
192 | public void DeleteAllChildren() | 192 | public void DeleteAllChildren() |
193 | { | 193 | { |
194 | this.children.Clear(); | 194 | this.children.Clear(); |
195 | this.ChildPrimitives.Clear(); | 195 | this.ChildPrimitives.Clear(); |
196 | this.rootPrimitive = null; | 196 | this.rootPrimitive = null; |
197 | unregisterEvents(); | 197 | unregisterEvents(); |
198 | } | 198 | } |
199 | 199 | ||
200 | /// <summary> | 200 | /// <summary> |
201 | /// | 201 | /// |
202 | /// </summary> | 202 | /// </summary> |
203 | /// <param name="primObject"></param> | 203 | /// <param name="primObject"></param> |
204 | public void AddNewChildPrims(SceneObject primObject) | 204 | public void AddNewChildPrims(SceneObject primObject) |
205 | { | 205 | { |
206 | this.rootPrimitive.AddNewChildren(primObject); | 206 | this.rootPrimitive.AddNewChildren(primObject); |
207 | } | 207 | } |
208 | 208 | ||
209 | public void AddChildToList(Primitive prim) | 209 | public void AddChildToList(Primitive prim) |
210 | { | 210 | { |
211 | if (!this.ChildPrimitives.ContainsKey(prim.uuid)) | 211 | if (!this.ChildPrimitives.ContainsKey(prim.uuid)) |
212 | { | 212 | { |
213 | this.ChildPrimitives.Add(prim.uuid, prim); | 213 | this.ChildPrimitives.Add(prim.uuid, prim); |
214 | } | 214 | } |
215 | } | 215 | } |
216 | /// <summary> | 216 | /// <summary> |
217 | /// | 217 | /// |
218 | /// </summary> | 218 | /// </summary> |
219 | /// <param name="primID"></param> | 219 | /// <param name="primID"></param> |
220 | /// <returns></returns> | 220 | /// <returns></returns> |
221 | public Primitive HasChildPrim(LLUUID primID) | 221 | public Primitive HasChildPrim(LLUUID primID) |
222 | { | 222 | { |
223 | if (this.ChildPrimitives.ContainsKey(primID)) | 223 | if (this.ChildPrimitives.ContainsKey(primID)) |
224 | { | 224 | { |
225 | return this.ChildPrimitives[primID]; | 225 | return this.ChildPrimitives[primID]; |
226 | } | 226 | } |
227 | 227 | ||
228 | return null; | 228 | return null; |
229 | } | 229 | } |
230 | 230 | ||
231 | /// <summary> | 231 | /// <summary> |
232 | /// | 232 | /// |
233 | /// </summary> | 233 | /// </summary> |
234 | /// <param name="localID"></param> | 234 | /// <param name="localID"></param> |
235 | /// <returns></returns> | 235 | /// <returns></returns> |
236 | public Primitive HasChildPrim(uint localID) | 236 | public Primitive HasChildPrim(uint localID) |
237 | { | 237 | { |
238 | Primitive returnPrim = null; | 238 | Primitive returnPrim = null; |
239 | foreach (Primitive prim in this.ChildPrimitives.Values) | 239 | foreach (Primitive prim in this.ChildPrimitives.Values) |
240 | { | 240 | { |
241 | if (prim.LocalId == localID) | 241 | if (prim.LocalId == localID) |
242 | { | 242 | { |
243 | returnPrim = prim; | 243 | returnPrim = prim; |
244 | break; | 244 | break; |
245 | } | 245 | } |
246 | } | 246 | } |
247 | return returnPrim; | 247 | return returnPrim; |
248 | } | 248 | } |
249 | 249 | ||
250 | public void SendAllChildPrimsToClient(IClientAPI client) | 250 | public void SendAllChildPrimsToClient(IClientAPI client) |
251 | { | 251 | { |
252 | this.rootPrimitive.SendFullUpdateForAllChildren(client); | 252 | this.rootPrimitive.SendFullUpdateForAllChildren(client); |
253 | } | 253 | } |
254 | 254 | ||
255 | /// <summary> | 255 | /// <summary> |
256 | /// | 256 | /// |
257 | /// </summary> | 257 | /// </summary> |
258 | public override void BackUp() | 258 | public override void BackUp() |
259 | { | 259 | { |
260 | 260 | ||
261 | } | 261 | } |
262 | 262 | ||
263 | /// <summary> | 263 | /// <summary> |
264 | /// | 264 | /// |
265 | /// </summary> | 265 | /// </summary> |
266 | /// <param name="offset"></param> | 266 | /// <param name="offset"></param> |
267 | /// <param name="pos"></param> | 267 | /// <param name="pos"></param> |
268 | /// <param name="remoteClient"></param> | 268 | /// <param name="remoteClient"></param> |
269 | public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) | 269 | public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) |
270 | { | 270 | { |
271 | this.rootPrimitive.Pos = pos; | 271 | this.rootPrimitive.Pos = pos; |
272 | this.rootPrimitive.SendTerseUpdateForAllChildren(remoteClient); | 272 | this.rootPrimitive.SendTerseUpdateForAllChildren(remoteClient); |
273 | } | 273 | } |
274 | 274 | ||
275 | /// <summary> | 275 | /// <summary> |
276 | /// | 276 | /// |
277 | /// </summary> | 277 | /// </summary> |
278 | /// <param name="client"></param> | 278 | /// <param name="client"></param> |
279 | public void GetProperites(IClientAPI client) | 279 | public void GetProperites(IClientAPI client) |
280 | { | 280 | { |
281 | ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); | 281 | ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); |
282 | proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; | 282 | proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; |
283 | proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); | 283 | proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); |
284 | proper.ObjectData[0].ItemID = LLUUID.Zero; | 284 | proper.ObjectData[0].ItemID = LLUUID.Zero; |
285 | proper.ObjectData[0].CreationDate = (ulong)this.rootPrimitive.CreationDate; | 285 | proper.ObjectData[0].CreationDate = (ulong)this.rootPrimitive.CreationDate; |
286 | proper.ObjectData[0].CreatorID = this.rootPrimitive.CreatorID; | 286 | proper.ObjectData[0].CreatorID = this.rootPrimitive.CreatorID; |
287 | proper.ObjectData[0].FolderID = LLUUID.Zero; | 287 | proper.ObjectData[0].FolderID = LLUUID.Zero; |
288 | proper.ObjectData[0].FromTaskID = LLUUID.Zero; | 288 | proper.ObjectData[0].FromTaskID = LLUUID.Zero; |
289 | proper.ObjectData[0].GroupID = LLUUID.Zero; | 289 | proper.ObjectData[0].GroupID = LLUUID.Zero; |
290 | proper.ObjectData[0].InventorySerial = 0; | 290 | proper.ObjectData[0].InventorySerial = 0; |
291 | proper.ObjectData[0].LastOwnerID = this.rootPrimitive.LastOwnerID; | 291 | proper.ObjectData[0].LastOwnerID = this.rootPrimitive.LastOwnerID; |
292 | proper.ObjectData[0].ObjectID = this.rootUUID; | 292 | proper.ObjectData[0].ObjectID = this.rootUUID; |
293 | proper.ObjectData[0].OwnerID = this.rootPrimitive.OwnerID; | 293 | proper.ObjectData[0].OwnerID = this.rootPrimitive.OwnerID; |
294 | proper.ObjectData[0].TouchName = enc.GetBytes(this.rootPrimitive.TouchName + "\0"); | 294 | proper.ObjectData[0].TouchName = enc.GetBytes(this.rootPrimitive.TouchName + "\0"); |
295 | proper.ObjectData[0].TextureID = new byte[0]; | 295 | proper.ObjectData[0].TextureID = new byte[0]; |
296 | proper.ObjectData[0].SitName = enc.GetBytes(this.rootPrimitive.SitName + "\0"); | 296 | proper.ObjectData[0].SitName = enc.GetBytes(this.rootPrimitive.SitName + "\0"); |
297 | proper.ObjectData[0].Name = enc.GetBytes(this.rootPrimitive.Name + "\0"); | 297 | proper.ObjectData[0].Name = enc.GetBytes(this.rootPrimitive.Name + "\0"); |
298 | proper.ObjectData[0].Description = enc.GetBytes(this.rootPrimitive.Description + "\0"); | 298 | proper.ObjectData[0].Description = enc.GetBytes(this.rootPrimitive.Description + "\0"); |
299 | proper.ObjectData[0].OwnerMask = this.rootPrimitive.OwnerMask; | 299 | proper.ObjectData[0].OwnerMask = this.rootPrimitive.OwnerMask; |
300 | proper.ObjectData[0].NextOwnerMask = this.rootPrimitive.NextOwnerMask; | 300 | proper.ObjectData[0].NextOwnerMask = this.rootPrimitive.NextOwnerMask; |
301 | proper.ObjectData[0].GroupMask = this.rootPrimitive.GroupMask; | 301 | proper.ObjectData[0].GroupMask = this.rootPrimitive.GroupMask; |
302 | proper.ObjectData[0].EveryoneMask = this.rootPrimitive.EveryoneMask; | 302 | proper.ObjectData[0].EveryoneMask = this.rootPrimitive.EveryoneMask; |
303 | proper.ObjectData[0].BaseMask = this.rootPrimitive.BaseMask; | 303 | proper.ObjectData[0].BaseMask = this.rootPrimitive.BaseMask; |
304 | 304 | ||
305 | client.OutPacket(proper); | 305 | client.OutPacket(proper); |
306 | } | 306 | } |
307 | 307 | ||
308 | } | 308 | } |
309 | } | 309 | } |
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs index d1f75ed..e88ee71 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs | |||
@@ -1,74 +1,74 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Xml; | 29 | using System.Xml; |
30 | using libsecondlife; | 30 | using libsecondlife; |
31 | 31 | ||
32 | namespace OpenSim.Region.Environment.Scenes | 32 | namespace OpenSim.Region.Environment.Scenes |
33 | { | 33 | { |
34 | partial class ScenePresence | 34 | partial class ScenePresence |
35 | { | 35 | { |
36 | public class AvatarAnimations | 36 | public class AvatarAnimations |
37 | { | 37 | { |
38 | 38 | ||
39 | public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>(); | 39 | public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>(); |
40 | public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>(); | 40 | public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>(); |
41 | 41 | ||
42 | public AvatarAnimations() | 42 | public AvatarAnimations() |
43 | { | 43 | { |
44 | } | 44 | } |
45 | 45 | ||
46 | public void LoadAnims() | 46 | public void LoadAnims() |
47 | { | 47 | { |
48 | //OpenSim.Framework.Console.MainLog.Instance.Verbose("Avatar.cs:LoadAnims() - Loading avatar animations"); | 48 | //OpenSim.Framework.Console.MainLog.Instance.Verbose("Avatar.cs:LoadAnims() - Loading avatar animations"); |
49 | XmlTextReader reader = new XmlTextReader("data/avataranimations.xml"); | 49 | XmlTextReader reader = new XmlTextReader("data/avataranimations.xml"); |
50 | 50 | ||
51 | XmlDocument doc = new XmlDocument(); | 51 | XmlDocument doc = new XmlDocument(); |
52 | doc.Load(reader); | 52 | doc.Load(reader); |
53 | foreach (XmlNode nod in doc.DocumentElement.ChildNodes) | 53 | foreach (XmlNode nod in doc.DocumentElement.ChildNodes) |
54 | { | 54 | { |
55 | 55 | ||
56 | if (nod.Attributes["name"] != null) | 56 | if (nod.Attributes["name"] != null) |
57 | { | 57 | { |
58 | AnimsLLUUID.Add(nod.Attributes["name"].Value, nod.InnerText); | 58 | AnimsLLUUID.Add(nod.Attributes["name"].Value, nod.InnerText); |
59 | } | 59 | } |
60 | 60 | ||
61 | } | 61 | } |
62 | 62 | ||
63 | reader.Close(); | 63 | reader.Close(); |
64 | 64 | ||
65 | // OpenSim.Framework.Console.MainLog.Instance.Verbose("Loaded " + AnimsLLUUID.Count.ToString() + " animation(s)"); | 65 | // OpenSim.Framework.Console.MainLog.Instance.Verbose("Loaded " + AnimsLLUUID.Count.ToString() + " animation(s)"); |
66 | 66 | ||
67 | foreach (KeyValuePair<string, LLUUID> kp in Animations.AnimsLLUUID) | 67 | foreach (KeyValuePair<string, LLUUID> kp in Animations.AnimsLLUUID) |
68 | { | 68 | { |
69 | AnimsNames.Add(kp.Value, kp.Key); | 69 | AnimsNames.Add(kp.Value, kp.Key); |
70 | } | 70 | } |
71 | } | 71 | } |
72 | } | 72 | } |
73 | } | 73 | } |
74 | } | 74 | } |
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs index dbb5d3f..c2599a1 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs | |||
@@ -1,85 +1,85 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using libsecondlife; | 28 | using libsecondlife; |
29 | using libsecondlife.Packets; | 29 | using libsecondlife.Packets; |
30 | using OpenSim.Framework.Interfaces; | 30 | using OpenSim.Framework.Interfaces; |
31 | 31 | ||
32 | namespace OpenSim.Region.Environment.Scenes | 32 | namespace OpenSim.Region.Environment.Scenes |
33 | { | 33 | { |
34 | partial class ScenePresence | 34 | partial class ScenePresence |
35 | { | 35 | { |
36 | public class Avatar : IScenePresenceBody | 36 | public class Avatar : IScenePresenceBody |
37 | { | 37 | { |
38 | public Avatar() | 38 | public Avatar() |
39 | { | 39 | { |
40 | 40 | ||
41 | } | 41 | } |
42 | 42 | ||
43 | public void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) | 43 | public void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) |
44 | { | 44 | { |
45 | } | 45 | } |
46 | 46 | ||
47 | public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) | 47 | public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) |
48 | { | 48 | { |
49 | } | 49 | } |
50 | 50 | ||
51 | public void SendOurAppearance(IClientAPI OurClient) | 51 | public void SendOurAppearance(IClientAPI OurClient) |
52 | { | 52 | { |
53 | } | 53 | } |
54 | 54 | ||
55 | public void SendAppearanceToOtherAgent(ScenePresence avatarInfo) | 55 | public void SendAppearanceToOtherAgent(ScenePresence avatarInfo) |
56 | { | 56 | { |
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 | ||
60 | public class ChildAgent : IScenePresenceBody //is a ghost | 60 | public class ChildAgent : IScenePresenceBody //is a ghost |
61 | { | 61 | { |
62 | public ChildAgent() | 62 | public ChildAgent() |
63 | { | 63 | { |
64 | 64 | ||
65 | } | 65 | } |
66 | 66 | ||
67 | public void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) | 67 | public void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) |
68 | { | 68 | { |
69 | } | 69 | } |
70 | 70 | ||
71 | public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) | 71 | public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | public void SendOurAppearance(IClientAPI OurClient) | 75 | public void SendOurAppearance(IClientAPI OurClient) |
76 | { | 76 | { |
77 | } | 77 | } |
78 | 78 | ||
79 | public void SendAppearanceToOtherAgent(ScenePresence avatarInfo) | 79 | public void SendAppearanceToOtherAgent(ScenePresence avatarInfo) |
80 | { | 80 | { |
81 | } | 81 | } |
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
85 | } | 85 | } |
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index b619b59..ae49d9f 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs | |||
@@ -1,623 +1,623 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | 30 | using System.IO; |
31 | using Axiom.Math; | 31 | using Axiom.Math; |
32 | using libsecondlife; | 32 | using libsecondlife; |
33 | using libsecondlife.Packets; | 33 | using libsecondlife.Packets; |
34 | using OpenSim.Framework.Console; | 34 | using OpenSim.Framework.Console; |
35 | using OpenSim.Framework.Interfaces; | 35 | using OpenSim.Framework.Interfaces; |
36 | using OpenSim.Framework.Types; | 36 | using OpenSim.Framework.Types; |
37 | using OpenSim.Physics.Manager; | 37 | using OpenSim.Physics.Manager; |
38 | 38 | ||
39 | namespace OpenSim.Region.Environment.Scenes | 39 | namespace OpenSim.Region.Environment.Scenes |
40 | { | 40 | { |
41 | public partial class ScenePresence : Entity | 41 | public partial class ScenePresence : Entity |
42 | { | 42 | { |
43 | public static bool PhysicsEngineFlying = false; | 43 | public static bool PhysicsEngineFlying = false; |
44 | public static AvatarAnimations Animations; | 44 | public static AvatarAnimations Animations; |
45 | public static byte[] DefaultTexture; | 45 | public static byte[] DefaultTexture; |
46 | public string firstname; | 46 | public string firstname; |
47 | public string lastname; | 47 | public string lastname; |
48 | public IClientAPI ControllingClient; | 48 | public IClientAPI ControllingClient; |
49 | public LLUUID current_anim; | 49 | public LLUUID current_anim; |
50 | public int anim_seq; | 50 | public int anim_seq; |
51 | private bool updateflag = false; | 51 | private bool updateflag = false; |
52 | private byte movementflag = 0; | 52 | private byte movementflag = 0; |
53 | private List<NewForce> forcesList = new List<NewForce>(); | 53 | private List<NewForce> forcesList = new List<NewForce>(); |
54 | private short _updateCount = 0; | 54 | private short _updateCount = 0; |
55 | private Quaternion bodyRot; | 55 | private Quaternion bodyRot; |
56 | private LLObject.TextureEntry avatarAppearanceTexture = null; | 56 | private LLObject.TextureEntry avatarAppearanceTexture = null; |
57 | private byte[] visualParams; | 57 | private byte[] visualParams; |
58 | private AvatarWearable[] Wearables; | 58 | private AvatarWearable[] Wearables; |
59 | private ulong m_regionHandle; | 59 | private ulong m_regionHandle; |
60 | 60 | ||
61 | public bool childAgent = false; | 61 | public bool childAgent = false; |
62 | public bool IsRestrictedToRegion = false; | 62 | public bool IsRestrictedToRegion = false; |
63 | 63 | ||
64 | private bool newForce = false; | 64 | private bool newForce = false; |
65 | private bool newAvatar = false; | 65 | private bool newAvatar = false; |
66 | private IScenePresenceBody m_body; | 66 | private IScenePresenceBody m_body; |
67 | 67 | ||
68 | protected RegionInfo m_regionInfo; | 68 | protected RegionInfo m_regionInfo; |
69 | 69 | ||
70 | private Vector3[] Dir_Vectors = new Vector3[6]; | 70 | private Vector3[] Dir_Vectors = new Vector3[6]; |
71 | private enum Dir_ControlFlags | 71 | private enum Dir_ControlFlags |
72 | { | 72 | { |
73 | DIR_CONTROL_FLAG_FOWARD = MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS, | 73 | DIR_CONTROL_FLAG_FOWARD = MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS, |
74 | DIR_CONTROL_FLAG_BACK = MainAvatar.ControlFlags.AGENT_CONTROL_AT_NEG, | 74 | DIR_CONTROL_FLAG_BACK = MainAvatar.ControlFlags.AGENT_CONTROL_AT_NEG, |
75 | DIR_CONTROL_FLAG_LEFT = MainAvatar.ControlFlags.AGENT_CONTROL_LEFT_POS, | 75 | DIR_CONTROL_FLAG_LEFT = MainAvatar.ControlFlags.AGENT_CONTROL_LEFT_POS, |
76 | DIR_CONTROL_FLAG_RIGHT = MainAvatar.ControlFlags.AGENT_CONTROL_LEFT_NEG, | 76 | DIR_CONTROL_FLAG_RIGHT = MainAvatar.ControlFlags.AGENT_CONTROL_LEFT_NEG, |
77 | DIR_CONTROL_FLAG_UP = MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS, | 77 | DIR_CONTROL_FLAG_UP = MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS, |
78 | DIR_CONTROL_FLAG_DOWN = MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG | 78 | DIR_CONTROL_FLAG_DOWN = MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG |
79 | } | 79 | } |
80 | /// <summary> | 80 | /// <summary> |
81 | /// Position at which a significant movement was made | 81 | /// Position at which a significant movement was made |
82 | /// </summary> | 82 | /// </summary> |
83 | private LLVector3 posLastSignificantMove = new LLVector3(); | 83 | private LLVector3 posLastSignificantMove = new LLVector3(); |
84 | 84 | ||
85 | public delegate void SignificantClientMovement(IClientAPI remote_client); | 85 | public delegate void SignificantClientMovement(IClientAPI remote_client); |
86 | public event SignificantClientMovement OnSignificantClientMovement; | 86 | public event SignificantClientMovement OnSignificantClientMovement; |
87 | 87 | ||
88 | #region Properties | 88 | #region Properties |
89 | /// <summary> | 89 | /// <summary> |
90 | /// | 90 | /// |
91 | /// </summary> | 91 | /// </summary> |
92 | public PhysicsActor PhysActor | 92 | public PhysicsActor PhysActor |
93 | { | 93 | { |
94 | set | 94 | set |
95 | { | 95 | { |
96 | this._physActor = value; | 96 | this._physActor = value; |
97 | } | 97 | } |
98 | get | 98 | get |
99 | { | 99 | { |
100 | return _physActor; | 100 | return _physActor; |
101 | } | 101 | } |
102 | } | 102 | } |
103 | 103 | ||
104 | public ulong RegionHandle | 104 | public ulong RegionHandle |
105 | { | 105 | { |
106 | get { return m_regionHandle; } | 106 | get { return m_regionHandle; } |
107 | } | 107 | } |
108 | 108 | ||
109 | #endregion | 109 | #endregion |
110 | 110 | ||
111 | #region Constructor(s) | 111 | #region Constructor(s) |
112 | /// <summary> | 112 | /// <summary> |
113 | /// | 113 | /// |
114 | /// </summary> | 114 | /// </summary> |
115 | /// <param name="theClient"></param> | 115 | /// <param name="theClient"></param> |
116 | /// <param name="world"></param> | 116 | /// <param name="world"></param> |
117 | /// <param name="clientThreads"></param> | 117 | /// <param name="clientThreads"></param> |
118 | /// <param name="regionDat"></param> | 118 | /// <param name="regionDat"></param> |
119 | public ScenePresence(IClientAPI theClient, Scene world, RegionInfo reginfo) | 119 | public ScenePresence(IClientAPI theClient, Scene world, RegionInfo reginfo) |
120 | { | 120 | { |
121 | 121 | ||
122 | m_world = world; | 122 | m_world = world; |
123 | this.uuid = theClient.AgentId; | 123 | this.uuid = theClient.AgentId; |
124 | 124 | ||
125 | m_regionInfo = reginfo; | 125 | m_regionInfo = reginfo; |
126 | m_regionHandle = reginfo.RegionHandle; | 126 | m_regionHandle = reginfo.RegionHandle; |
127 | MainLog.Instance.Verbose("Avatar.cs "); | 127 | MainLog.Instance.Verbose("Avatar.cs "); |
128 | ControllingClient = theClient; | 128 | ControllingClient = theClient; |
129 | this.firstname = ControllingClient.FirstName; | 129 | this.firstname = ControllingClient.FirstName; |
130 | this.lastname = ControllingClient.LastName; | 130 | this.lastname = ControllingClient.LastName; |
131 | m_localId = m_world.NextLocalId; | 131 | m_localId = m_world.NextLocalId; |
132 | Pos = ControllingClient.StartPos; | 132 | Pos = ControllingClient.StartPos; |
133 | visualParams = new byte[218]; | 133 | visualParams = new byte[218]; |
134 | for (int i = 0; i < 218; i++) | 134 | for (int i = 0; i < 218; i++) |
135 | { | 135 | { |
136 | visualParams[i] = 100; | 136 | visualParams[i] = 100; |
137 | } | 137 | } |
138 | 138 | ||
139 | Wearables = AvatarWearable.DefaultWearables; | 139 | Wearables = AvatarWearable.DefaultWearables; |
140 | Animations = new ScenePresence.AvatarAnimations(); | 140 | Animations = new ScenePresence.AvatarAnimations(); |
141 | Animations.LoadAnims(); | 141 | Animations.LoadAnims(); |
142 | 142 | ||
143 | this.avatarAppearanceTexture = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); | 143 | this.avatarAppearanceTexture = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); |
144 | 144 | ||
145 | //register for events | 145 | //register for events |
146 | ControllingClient.OnRequestWearables += this.SendOurAppearance; | 146 | ControllingClient.OnRequestWearables += this.SendOurAppearance; |
147 | //ControllingClient.OnSetAppearance += new SetAppearance(this.SetAppearance); | 147 | //ControllingClient.OnSetAppearance += new SetAppearance(this.SetAppearance); |
148 | ControllingClient.OnCompleteMovementToRegion += this.CompleteMovement; | 148 | ControllingClient.OnCompleteMovementToRegion += this.CompleteMovement; |
149 | ControllingClient.OnCompleteMovementToRegion += this.SendInitialData; | 149 | ControllingClient.OnCompleteMovementToRegion += this.SendInitialData; |
150 | ControllingClient.OnAgentUpdate += this.HandleAgentUpdate; | 150 | ControllingClient.OnAgentUpdate += this.HandleAgentUpdate; |
151 | // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); | 151 | // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); |
152 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); | 152 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); |
153 | //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); | 153 | //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); |
154 | 154 | ||
155 | Dir_Vectors[0] = new Vector3(1, 0, 0); //FOWARD | 155 | Dir_Vectors[0] = new Vector3(1, 0, 0); //FOWARD |
156 | Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK | 156 | Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK |
157 | Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT | 157 | Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT |
158 | Dir_Vectors[3] = new Vector3(0, -1, 0); //RIGHT | 158 | Dir_Vectors[3] = new Vector3(0, -1, 0); //RIGHT |
159 | Dir_Vectors[4] = new Vector3(0, 0, 1); //UP | 159 | Dir_Vectors[4] = new Vector3(0, 0, 1); //UP |
160 | Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN | 160 | Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN |
161 | 161 | ||
162 | } | 162 | } |
163 | #endregion | 163 | #endregion |
164 | 164 | ||
165 | #region Status Methods | 165 | #region Status Methods |
166 | /// <summary> | 166 | /// <summary> |
167 | /// Not Used, most likely can be deleted | 167 | /// Not Used, most likely can be deleted |
168 | /// </summary> | 168 | /// </summary> |
169 | /// <param name="status"></param> | 169 | /// <param name="status"></param> |
170 | public void ChildStatusChange(bool status) | 170 | public void ChildStatusChange(bool status) |
171 | { | 171 | { |
172 | this.childAgent = status; | 172 | this.childAgent = status; |
173 | 173 | ||
174 | if (this.childAgent == true) | 174 | if (this.childAgent == true) |
175 | { | 175 | { |
176 | this.Velocity = new LLVector3(0, 0, 0); | 176 | this.Velocity = new LLVector3(0, 0, 0); |
177 | this.Pos = new LLVector3(128, 128, 70); | 177 | this.Pos = new LLVector3(128, 128, 70); |
178 | 178 | ||
179 | } | 179 | } |
180 | } | 180 | } |
181 | 181 | ||
182 | /// <summary> | 182 | /// <summary> |
183 | /// | 183 | /// |
184 | /// </summary> | 184 | /// </summary> |
185 | /// <param name="pos"></param> | 185 | /// <param name="pos"></param> |
186 | public void MakeAvatar(LLVector3 pos) | 186 | public void MakeAvatar(LLVector3 pos) |
187 | { | 187 | { |
188 | //this.childAvatar = false; | 188 | //this.childAvatar = false; |
189 | this.Pos = pos; | 189 | this.Pos = pos; |
190 | this.newAvatar = true; | 190 | this.newAvatar = true; |
191 | this.childAgent = false; | 191 | this.childAgent = false; |
192 | } | 192 | } |
193 | 193 | ||
194 | protected void MakeChildAgent() | 194 | protected void MakeChildAgent() |
195 | { | 195 | { |
196 | this.Velocity = new LLVector3(0, 0, 0); | 196 | this.Velocity = new LLVector3(0, 0, 0); |
197 | this.Pos = new LLVector3(128, 128, 70); | 197 | this.Pos = new LLVector3(128, 128, 70); |
198 | this.childAgent = true; | 198 | this.childAgent = true; |
199 | } | 199 | } |
200 | 200 | ||
201 | /// <summary> | 201 | /// <summary> |
202 | /// | 202 | /// |
203 | /// </summary> | 203 | /// </summary> |
204 | /// <param name="pos"></param> | 204 | /// <param name="pos"></param> |
205 | public void Teleport(LLVector3 pos) | 205 | public void Teleport(LLVector3 pos) |
206 | { | 206 | { |
207 | this.Pos = pos; | 207 | this.Pos = pos; |
208 | this.SendTerseUpdateToALLClients(); | 208 | this.SendTerseUpdateToALLClients(); |
209 | } | 209 | } |
210 | 210 | ||
211 | /// <summary> | 211 | /// <summary> |
212 | /// | 212 | /// |
213 | /// </summary> | 213 | /// </summary> |
214 | public void StopMovement() | 214 | public void StopMovement() |
215 | { | 215 | { |
216 | 216 | ||
217 | } | 217 | } |
218 | #endregion | 218 | #endregion |
219 | 219 | ||
220 | #region Event Handlers | 220 | #region Event Handlers |
221 | /// <summary> | 221 | /// <summary> |
222 | /// | 222 | /// |
223 | /// </summary> | 223 | /// </summary> |
224 | /// <param name="texture"></param> | 224 | /// <param name="texture"></param> |
225 | /// <param name="visualParam"></param> | 225 | /// <param name="visualParam"></param> |
226 | public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) | 226 | public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) |
227 | { | 227 | { |
228 | 228 | ||
229 | } | 229 | } |
230 | 230 | ||
231 | /// <summary> | 231 | /// <summary> |
232 | /// Complete Avatar's movement into the region | 232 | /// Complete Avatar's movement into the region |
233 | /// </summary> | 233 | /// </summary> |
234 | public void CompleteMovement() | 234 | public void CompleteMovement() |
235 | { | 235 | { |
236 | LLVector3 look = this.Velocity; | 236 | LLVector3 look = this.Velocity; |
237 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) | 237 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) |
238 | { | 238 | { |
239 | look = new LLVector3(0.99f, 0.042f, 0); | 239 | look = new LLVector3(0.99f, 0.042f, 0); |
240 | } | 240 | } |
241 | this.ControllingClient.MoveAgentIntoRegion(m_regionInfo, Pos, look); | 241 | this.ControllingClient.MoveAgentIntoRegion(m_regionInfo, Pos, look); |
242 | if (this.childAgent) | 242 | if (this.childAgent) |
243 | { | 243 | { |
244 | this.childAgent = false; | 244 | this.childAgent = false; |
245 | } | 245 | } |
246 | } | 246 | } |
247 | 247 | ||
248 | /// <summary> | 248 | /// <summary> |
249 | /// | 249 | /// |
250 | /// </summary> | 250 | /// </summary> |
251 | /// <param name="pack"></param> | 251 | /// <param name="pack"></param> |
252 | public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) | 252 | public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) |
253 | { | 253 | { |
254 | int i = 0; | 254 | int i = 0; |
255 | bool update_movementflag = false; | 255 | bool update_movementflag = false; |
256 | bool update_rotation = false; | 256 | bool update_rotation = false; |
257 | bool DCFlagKeyPressed = false; | 257 | bool DCFlagKeyPressed = false; |
258 | Vector3 agent_control_v3 = new Vector3(0, 0, 0); | 258 | Vector3 agent_control_v3 = new Vector3(0, 0, 0); |
259 | Quaternion q = new Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z); | 259 | Quaternion q = new Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z); |
260 | 260 | ||
261 | this.PhysActor.Flying = ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0); | 261 | this.PhysActor.Flying = ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0); |
262 | 262 | ||
263 | if (q != this.bodyRot) | 263 | if (q != this.bodyRot) |
264 | { | 264 | { |
265 | this.bodyRot = q; | 265 | this.bodyRot = q; |
266 | update_rotation = true; | 266 | update_rotation = true; |
267 | } | 267 | } |
268 | foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof(Dir_ControlFlags))) | 268 | foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof(Dir_ControlFlags))) |
269 | { | 269 | { |
270 | if ((flags & (uint)DCF) != 0) | 270 | if ((flags & (uint)DCF) != 0) |
271 | { | 271 | { |
272 | DCFlagKeyPressed = true; | 272 | DCFlagKeyPressed = true; |
273 | agent_control_v3 += Dir_Vectors[i]; | 273 | agent_control_v3 += Dir_Vectors[i]; |
274 | if ((movementflag & (uint)DCF) == 0) | 274 | if ((movementflag & (uint)DCF) == 0) |
275 | { | 275 | { |
276 | movementflag += (byte)(uint)DCF; | 276 | movementflag += (byte)(uint)DCF; |
277 | update_movementflag = true; | 277 | update_movementflag = true; |
278 | } | 278 | } |
279 | } | 279 | } |
280 | else | 280 | else |
281 | { | 281 | { |
282 | if ((movementflag & (uint)DCF) != 0) | 282 | if ((movementflag & (uint)DCF) != 0) |
283 | { | 283 | { |
284 | movementflag -= (byte)(uint)DCF; | 284 | movementflag -= (byte)(uint)DCF; |
285 | update_movementflag = true; | 285 | update_movementflag = true; |
286 | 286 | ||
287 | } | 287 | } |
288 | } | 288 | } |
289 | i++; | 289 | i++; |
290 | } | 290 | } |
291 | if ((update_movementflag) || (update_rotation && DCFlagKeyPressed)) | 291 | if ((update_movementflag) || (update_rotation && DCFlagKeyPressed)) |
292 | { | 292 | { |
293 | this.AddNewMovement(agent_control_v3, q); | 293 | this.AddNewMovement(agent_control_v3, q); |
294 | } | 294 | } |
295 | UpdateMovementAnimations(update_movementflag); | 295 | UpdateMovementAnimations(update_movementflag); |
296 | } | 296 | } |
297 | 297 | ||
298 | protected void UpdateMovementAnimations(bool update_movementflag) | 298 | protected void UpdateMovementAnimations(bool update_movementflag) |
299 | { | 299 | { |
300 | if (update_movementflag) | 300 | if (update_movementflag) |
301 | { | 301 | { |
302 | if (movementflag != 0) | 302 | if (movementflag != 0) |
303 | { | 303 | { |
304 | if (this._physActor.Flying) | 304 | if (this._physActor.Flying) |
305 | { | 305 | { |
306 | this.SendAnimPack(Animations.AnimsLLUUID["FLY"], 1); | 306 | this.SendAnimPack(Animations.AnimsLLUUID["FLY"], 1); |
307 | } | 307 | } |
308 | else | 308 | else |
309 | { | 309 | { |
310 | this.SendAnimPack(Animations.AnimsLLUUID["WALK"], 1); | 310 | this.SendAnimPack(Animations.AnimsLLUUID["WALK"], 1); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | else | 313 | else |
314 | { | 314 | { |
315 | this.SendAnimPack(Animations.AnimsLLUUID["STAND"], 1); | 315 | this.SendAnimPack(Animations.AnimsLLUUID["STAND"], 1); |
316 | } | 316 | } |
317 | } | 317 | } |
318 | 318 | ||
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | protected void AddNewMovement(Vector3 vec, Quaternion rotation) | 322 | protected void AddNewMovement(Vector3 vec, Quaternion rotation) |
323 | { | 323 | { |
324 | NewForce newVelocity = new NewForce(); | 324 | NewForce newVelocity = new NewForce(); |
325 | Vector3 direc = rotation * vec; | 325 | Vector3 direc = rotation * vec; |
326 | direc.Normalize(); | 326 | direc.Normalize(); |
327 | 327 | ||
328 | direc = direc * ((0.03f) * 128f); | 328 | direc = direc * ((0.03f) * 128f); |
329 | if (this._physActor.Flying) | 329 | if (this._physActor.Flying) |
330 | direc *= 4; | 330 | direc *= 4; |
331 | 331 | ||
332 | newVelocity.X = direc.x; | 332 | newVelocity.X = direc.x; |
333 | newVelocity.Y = direc.y; | 333 | newVelocity.Y = direc.y; |
334 | newVelocity.Z = direc.z; | 334 | newVelocity.Z = direc.z; |
335 | this.forcesList.Add(newVelocity); | 335 | this.forcesList.Add(newVelocity); |
336 | } | 336 | } |
337 | 337 | ||
338 | #endregion | 338 | #endregion |
339 | 339 | ||
340 | #region Overridden Methods | 340 | #region Overridden Methods |
341 | /// <summary> | 341 | /// <summary> |
342 | /// | 342 | /// |
343 | /// </summary> | 343 | /// </summary> |
344 | public override void LandRenegerated() | 344 | public override void LandRenegerated() |
345 | { | 345 | { |
346 | 346 | ||
347 | } | 347 | } |
348 | 348 | ||
349 | /// <summary> | 349 | /// <summary> |
350 | /// | 350 | /// |
351 | /// </summary> | 351 | /// </summary> |
352 | public override void update() | 352 | public override void update() |
353 | { | 353 | { |
354 | if (this.childAgent == false) | 354 | if (this.childAgent == false) |
355 | { | 355 | { |
356 | if (this.newForce) | 356 | if (this.newForce) |
357 | { | 357 | { |
358 | this.SendTerseUpdateToALLClients(); | 358 | this.SendTerseUpdateToALLClients(); |
359 | _updateCount = 0; | 359 | _updateCount = 0; |
360 | } | 360 | } |
361 | else if (movementflag != 0) | 361 | else if (movementflag != 0) |
362 | { | 362 | { |
363 | _updateCount++; | 363 | _updateCount++; |
364 | if (_updateCount > 3) | 364 | if (_updateCount > 3) |
365 | { | 365 | { |
366 | this.SendTerseUpdateToALLClients(); | 366 | this.SendTerseUpdateToALLClients(); |
367 | _updateCount = 0; | 367 | _updateCount = 0; |
368 | } | 368 | } |
369 | } | 369 | } |
370 | 370 | ||
371 | this.CheckForSignificantMovement(); | 371 | this.CheckForSignificantMovement(); |
372 | this.CheckForBorderCrossing(); | 372 | this.CheckForBorderCrossing(); |
373 | 373 | ||
374 | } | 374 | } |
375 | } | 375 | } |
376 | #endregion | 376 | #endregion |
377 | 377 | ||
378 | #region Update Client(s) | 378 | #region Update Client(s) |
379 | /// <summary> | 379 | /// <summary> |
380 | /// | 380 | /// |
381 | /// </summary> | 381 | /// </summary> |
382 | /// <param name="RemoteClient"></param> | 382 | /// <param name="RemoteClient"></param> |
383 | public void SendTerseUpdateToClient(IClientAPI RemoteClient) | 383 | public void SendTerseUpdateToClient(IClientAPI RemoteClient) |
384 | { | 384 | { |
385 | LLVector3 pos = this.Pos; | 385 | LLVector3 pos = this.Pos; |
386 | LLVector3 vel = this.Velocity; | 386 | LLVector3 vel = this.Velocity; |
387 | RemoteClient.SendAvatarTerseUpdate(this.m_regionHandle, 64096, this.LocalId, new LLVector3(pos.X, pos.Y, pos.Z), new LLVector3(vel.X, vel.Y, vel.Z)); | 387 | RemoteClient.SendAvatarTerseUpdate(this.m_regionHandle, 64096, this.LocalId, new LLVector3(pos.X, pos.Y, pos.Z), new LLVector3(vel.X, vel.Y, vel.Z)); |
388 | } | 388 | } |
389 | 389 | ||
390 | /// <summary> | 390 | /// <summary> |
391 | /// | 391 | /// |
392 | /// </summary> | 392 | /// </summary> |
393 | public void SendTerseUpdateToALLClients() | 393 | public void SendTerseUpdateToALLClients() |
394 | { | 394 | { |
395 | List<ScenePresence> avatars = this.m_world.RequestAvatarList(); | 395 | List<ScenePresence> avatars = this.m_world.RequestAvatarList(); |
396 | for (int i = 0; i < avatars.Count; i++) | 396 | for (int i = 0; i < avatars.Count; i++) |
397 | { | 397 | { |
398 | this.SendTerseUpdateToClient(avatars[i].ControllingClient); | 398 | this.SendTerseUpdateToClient(avatars[i].ControllingClient); |
399 | } | 399 | } |
400 | } | 400 | } |
401 | 401 | ||
402 | /// <summary> | 402 | /// <summary> |
403 | /// | 403 | /// |
404 | /// </summary> | 404 | /// </summary> |
405 | /// <param name="remoteAvatar"></param> | 405 | /// <param name="remoteAvatar"></param> |
406 | public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) | 406 | public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) |
407 | { | 407 | { |
408 | remoteAvatar.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos, DefaultTexture); | 408 | remoteAvatar.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos, DefaultTexture); |
409 | } | 409 | } |
410 | 410 | ||
411 | public void SendFullUpdateToALLClients() | 411 | public void SendFullUpdateToALLClients() |
412 | { | 412 | { |
413 | List<ScenePresence> avatars = this.m_world.RequestAvatarList(); | 413 | List<ScenePresence> avatars = this.m_world.RequestAvatarList(); |
414 | foreach (ScenePresence avatar in this.m_world.RequestAvatarList()) | 414 | foreach (ScenePresence avatar in this.m_world.RequestAvatarList()) |
415 | { | 415 | { |
416 | this.SendFullUpdateToOtherClient(avatar); | 416 | this.SendFullUpdateToOtherClient(avatar); |
417 | avatar.SendFullUpdateToOtherClient(this); | 417 | avatar.SendFullUpdateToOtherClient(this); |
418 | } | 418 | } |
419 | } | 419 | } |
420 | 420 | ||
421 | /// <summary> | 421 | /// <summary> |
422 | /// | 422 | /// |
423 | /// </summary> | 423 | /// </summary> |
424 | public void SendInitialData() | 424 | public void SendInitialData() |
425 | { | 425 | { |
426 | this.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos, DefaultTexture); | 426 | this.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos, DefaultTexture); |
427 | if (this.newAvatar) | 427 | if (this.newAvatar) |
428 | { | 428 | { |
429 | this.m_world.InformClientOfNeighbours(this.ControllingClient); | 429 | this.m_world.InformClientOfNeighbours(this.ControllingClient); |
430 | this.newAvatar = false; | 430 | this.newAvatar = false; |
431 | } | 431 | } |
432 | } | 432 | } |
433 | 433 | ||
434 | /// <summary> | 434 | /// <summary> |
435 | /// | 435 | /// |
436 | /// </summary> | 436 | /// </summary> |
437 | /// <param name="OurClient"></param> | 437 | /// <param name="OurClient"></param> |
438 | public void SendOurAppearance(IClientAPI OurClient) | 438 | public void SendOurAppearance(IClientAPI OurClient) |
439 | { | 439 | { |
440 | this.ControllingClient.SendWearables(this.Wearables); | 440 | this.ControllingClient.SendWearables(this.Wearables); |
441 | this.SendFullUpdateToALLClients(); | 441 | this.SendFullUpdateToALLClients(); |
442 | this.m_world.SendAllSceneObjectsToClient(this.ControllingClient); | 442 | this.m_world.SendAllSceneObjectsToClient(this.ControllingClient); |
443 | } | 443 | } |
444 | 444 | ||
445 | /// <summary> | 445 | /// <summary> |
446 | /// | 446 | /// |
447 | /// </summary> | 447 | /// </summary> |
448 | /// <param name="avatarInfo"></param> | 448 | /// <param name="avatarInfo"></param> |
449 | public void SendAppearanceToOtherAgent(ScenePresence avatarInfo) | 449 | public void SendAppearanceToOtherAgent(ScenePresence avatarInfo) |
450 | { | 450 | { |
451 | 451 | ||
452 | } | 452 | } |
453 | 453 | ||
454 | /// <summary> | 454 | /// <summary> |
455 | /// | 455 | /// |
456 | /// </summary> | 456 | /// </summary> |
457 | /// <param name="animID"></param> | 457 | /// <param name="animID"></param> |
458 | /// <param name="seq"></param> | 458 | /// <param name="seq"></param> |
459 | public void SendAnimPack(LLUUID animID, int seq) | 459 | public void SendAnimPack(LLUUID animID, int seq) |
460 | { | 460 | { |
461 | this.current_anim = animID; | 461 | this.current_anim = animID; |
462 | this.anim_seq = seq; | 462 | this.anim_seq = seq; |
463 | List<ScenePresence> avatars = this.m_world.RequestAvatarList(); | 463 | List<ScenePresence> avatars = this.m_world.RequestAvatarList(); |
464 | for (int i = 0; i < avatars.Count; i++) | 464 | for (int i = 0; i < avatars.Count; i++) |
465 | { | 465 | { |
466 | avatars[i].ControllingClient.SendAnimation(animID, seq, this.ControllingClient.AgentId); | 466 | avatars[i].ControllingClient.SendAnimation(animID, seq, this.ControllingClient.AgentId); |
467 | } | 467 | } |
468 | } | 468 | } |
469 | 469 | ||
470 | /// <summary> | 470 | /// <summary> |
471 | /// | 471 | /// |
472 | /// </summary> | 472 | /// </summary> |
473 | public void SendAnimPack() | 473 | public void SendAnimPack() |
474 | { | 474 | { |
475 | this.SendAnimPack(this.current_anim, this.anim_seq); | 475 | this.SendAnimPack(this.current_anim, this.anim_seq); |
476 | } | 476 | } |
477 | #endregion | 477 | #endregion |
478 | 478 | ||
479 | #region Significant Movement Method | 479 | #region Significant Movement Method |
480 | 480 | ||
481 | protected void CheckForSignificantMovement() | 481 | protected void CheckForSignificantMovement() |
482 | { | 482 | { |
483 | if (libsecondlife.Helpers.VecDist(this.Pos, this.posLastSignificantMove) > 2.0) | 483 | if (libsecondlife.Helpers.VecDist(this.Pos, this.posLastSignificantMove) > 2.0) |
484 | { | 484 | { |
485 | this.posLastSignificantMove = this.Pos; | 485 | this.posLastSignificantMove = this.Pos; |
486 | if (OnSignificantClientMovement != null) | 486 | if (OnSignificantClientMovement != null) |
487 | { | 487 | { |
488 | OnSignificantClientMovement(this.ControllingClient); | 488 | OnSignificantClientMovement(this.ControllingClient); |
489 | } | 489 | } |
490 | } | 490 | } |
491 | } | 491 | } |
492 | #endregion | 492 | #endregion |
493 | #region Border Crossing Methods | 493 | #region Border Crossing Methods |
494 | /// <summary> | 494 | /// <summary> |
495 | /// | 495 | /// |
496 | /// </summary> | 496 | /// </summary> |
497 | protected void CheckForBorderCrossing() | 497 | protected void CheckForBorderCrossing() |
498 | { | 498 | { |
499 | LLVector3 pos2 = this.Pos; | 499 | LLVector3 pos2 = this.Pos; |
500 | LLVector3 vel = this.Velocity; | 500 | LLVector3 vel = this.Velocity; |
501 | 501 | ||
502 | float timeStep = 0.2f; | 502 | float timeStep = 0.2f; |
503 | pos2.X = pos2.X + (vel.X * timeStep); | 503 | pos2.X = pos2.X + (vel.X * timeStep); |
504 | pos2.Y = pos2.Y + (vel.Y * timeStep); | 504 | pos2.Y = pos2.Y + (vel.Y * timeStep); |
505 | pos2.Z = pos2.Z + (vel.Z * timeStep); | 505 | pos2.Z = pos2.Z + (vel.Z * timeStep); |
506 | 506 | ||
507 | if ((pos2.X < 0) || (pos2.X > 256)) | 507 | if ((pos2.X < 0) || (pos2.X > 256)) |
508 | { | 508 | { |
509 | this.CrossToNewRegion(); | 509 | this.CrossToNewRegion(); |
510 | } | 510 | } |
511 | 511 | ||
512 | if ((pos2.Y < 0) || (pos2.Y > 256)) | 512 | if ((pos2.Y < 0) || (pos2.Y > 256)) |
513 | { | 513 | { |
514 | this.CrossToNewRegion(); | 514 | this.CrossToNewRegion(); |
515 | } | 515 | } |
516 | } | 516 | } |
517 | 517 | ||
518 | /// <summary> | 518 | /// <summary> |
519 | /// | 519 | /// |
520 | /// </summary> | 520 | /// </summary> |
521 | protected void CrossToNewRegion() | 521 | protected void CrossToNewRegion() |
522 | { | 522 | { |
523 | LLVector3 pos = this.Pos; | 523 | LLVector3 pos = this.Pos; |
524 | LLVector3 newpos = new LLVector3(pos.X, pos.Y, pos.Z); | 524 | LLVector3 newpos = new LLVector3(pos.X, pos.Y, pos.Z); |
525 | uint neighbourx = this.m_regionInfo.RegionLocX; | 525 | uint neighbourx = this.m_regionInfo.RegionLocX; |
526 | uint neighboury = this.m_regionInfo.RegionLocY; | 526 | uint neighboury = this.m_regionInfo.RegionLocY; |
527 | 527 | ||
528 | if (pos.X < 2) | 528 | if (pos.X < 2) |
529 | { | 529 | { |
530 | neighbourx -= 1; | 530 | neighbourx -= 1; |
531 | newpos.X = 254; | 531 | newpos.X = 254; |
532 | } | 532 | } |
533 | if (pos.X > 253) | 533 | if (pos.X > 253) |
534 | { | 534 | { |
535 | neighbourx += 1; | 535 | neighbourx += 1; |
536 | newpos.X = 1; | 536 | newpos.X = 1; |
537 | } | 537 | } |
538 | if (pos.Y < 2) | 538 | if (pos.Y < 2) |
539 | { | 539 | { |
540 | neighboury -= 1; | 540 | neighboury -= 1; |
541 | newpos.Y = 254; | 541 | newpos.Y = 254; |
542 | } | 542 | } |
543 | if (pos.Y > 253) | 543 | if (pos.Y > 253) |
544 | { | 544 | { |
545 | neighboury += 1; | 545 | neighboury += 1; |
546 | newpos.Y = 1; | 546 | newpos.Y = 1; |
547 | } | 547 | } |
548 | 548 | ||
549 | LLVector3 vel = this.m_velocity; | 549 | LLVector3 vel = this.m_velocity; |
550 | ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * 256), (uint)(neighboury * 256)); | 550 | ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * 256), (uint)(neighboury * 256)); |
551 | RegionInfo neighbourRegion = this.m_world.RequestNeighbouringRegionInfo(neighbourHandle); | 551 | RegionInfo neighbourRegion = this.m_world.RequestNeighbouringRegionInfo(neighbourHandle); |
552 | if (neighbourRegion != null) | 552 | if (neighbourRegion != null) |
553 | { | 553 | { |
554 | bool res = this.m_world.InformNeighbourOfCrossing(neighbourHandle, this.ControllingClient.AgentId, newpos); | 554 | bool res = this.m_world.InformNeighbourOfCrossing(neighbourHandle, this.ControllingClient.AgentId, newpos); |
555 | if (res) | 555 | if (res) |
556 | { | 556 | { |
557 | this.MakeChildAgent(); | 557 | this.MakeChildAgent(); |
558 | this.ControllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.InternalEndPoint); | 558 | this.ControllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.InternalEndPoint); |
559 | } | 559 | } |
560 | } | 560 | } |
561 | } | 561 | } |
562 | #endregion | 562 | #endregion |
563 | 563 | ||
564 | /// <summary> | 564 | /// <summary> |
565 | /// | 565 | /// |
566 | /// </summary> | 566 | /// </summary> |
567 | public static void LoadAnims() | 567 | public static void LoadAnims() |
568 | { | 568 | { |
569 | 569 | ||
570 | } | 570 | } |
571 | 571 | ||
572 | /// <summary> | 572 | /// <summary> |
573 | /// | 573 | /// |
574 | /// </summary> | 574 | /// </summary> |
575 | public override void updateMovement() | 575 | public override void updateMovement() |
576 | { | 576 | { |
577 | newForce = false; | 577 | newForce = false; |
578 | lock (this.forcesList) | 578 | lock (this.forcesList) |
579 | { | 579 | { |
580 | if (this.forcesList.Count > 0) | 580 | if (this.forcesList.Count > 0) |
581 | { | 581 | { |
582 | for (int i = 0; i < this.forcesList.Count; i++) | 582 | for (int i = 0; i < this.forcesList.Count; i++) |
583 | { | 583 | { |
584 | NewForce force = this.forcesList[i]; | 584 | NewForce force = this.forcesList[i]; |
585 | 585 | ||
586 | this.updateflag = true; | 586 | this.updateflag = true; |
587 | this.Velocity = new LLVector3(force.X, force.Y, force.Z); | 587 | this.Velocity = new LLVector3(force.X, force.Y, force.Z); |
588 | this.newForce = true; | 588 | this.newForce = true; |
589 | } | 589 | } |
590 | for (int i = 0; i < this.forcesList.Count; i++) | 590 | for (int i = 0; i < this.forcesList.Count; i++) |
591 | { | 591 | { |
592 | this.forcesList.RemoveAt(0); | 592 | this.forcesList.RemoveAt(0); |
593 | } | 593 | } |
594 | } | 594 | } |
595 | } | 595 | } |
596 | } | 596 | } |
597 | 597 | ||
598 | public static void LoadTextureFile(string name) | 598 | public static void LoadTextureFile(string name) |
599 | { | 599 | { |
600 | FileInfo fInfo = new FileInfo(name); | 600 | FileInfo fInfo = new FileInfo(name); |
601 | long numBytes = fInfo.Length; | 601 | long numBytes = fInfo.Length; |
602 | FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); | 602 | FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); |
603 | BinaryReader br = new BinaryReader(fStream); | 603 | BinaryReader br = new BinaryReader(fStream); |
604 | byte[] data1 = br.ReadBytes((int)numBytes); | 604 | byte[] data1 = br.ReadBytes((int)numBytes); |
605 | br.Close(); | 605 | br.Close(); |
606 | fStream.Close(); | 606 | fStream.Close(); |
607 | DefaultTexture = data1; | 607 | DefaultTexture = data1; |
608 | } | 608 | } |
609 | 609 | ||
610 | public class NewForce | 610 | public class NewForce |
611 | { | 611 | { |
612 | public float X; | 612 | public float X; |
613 | public float Y; | 613 | public float Y; |
614 | public float Z; | 614 | public float Z; |
615 | 615 | ||
616 | public NewForce() | 616 | public NewForce() |
617 | { | 617 | { |
618 | 618 | ||
619 | } | 619 | } |
620 | } | 620 | } |
621 | } | 621 | } |
622 | 622 | ||
623 | } | 623 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/CSharpScriptEngine.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/CSharpScriptEngine.cs index 1fc576e..b0ccd22 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/CSharpScriptEngine.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/CSharpScriptEngine.cs | |||
@@ -1,102 +1,102 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.CodeDom.Compiler; | 29 | using System.CodeDom.Compiler; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using Microsoft.CSharp; | 31 | using Microsoft.CSharp; |
32 | using OpenSim.Framework.Console; | 32 | using OpenSim.Framework.Console; |
33 | 33 | ||
34 | namespace OpenSim.Region.Scripting | 34 | namespace OpenSim.Region.Scripting |
35 | { | 35 | { |
36 | public class CSharpScriptEngine : IScriptCompiler | 36 | public class CSharpScriptEngine : IScriptCompiler |
37 | { | 37 | { |
38 | public string FileExt() | 38 | public string FileExt() |
39 | { | 39 | { |
40 | return ".cs"; | 40 | return ".cs"; |
41 | } | 41 | } |
42 | 42 | ||
43 | private Dictionary<string,IScript> LoadDotNetScript(CodeDomProvider compiler, string filename) | 43 | private Dictionary<string,IScript> LoadDotNetScript(CodeDomProvider compiler, string filename) |
44 | { | 44 | { |
45 | CompilerParameters compilerParams = new CompilerParameters(); | 45 | CompilerParameters compilerParams = new CompilerParameters(); |
46 | CompilerResults compilerResults; | 46 | CompilerResults compilerResults; |
47 | compilerParams.GenerateExecutable = false; | 47 | compilerParams.GenerateExecutable = false; |
48 | compilerParams.GenerateInMemory = true; | 48 | compilerParams.GenerateInMemory = true; |
49 | compilerParams.IncludeDebugInformation = false; | 49 | compilerParams.IncludeDebugInformation = false; |
50 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll"); | 50 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll"); |
51 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll"); | 51 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll"); |
52 | compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll"); | 52 | compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll"); |
53 | compilerParams.ReferencedAssemblies.Add("libsecondlife.dll"); | 53 | compilerParams.ReferencedAssemblies.Add("libsecondlife.dll"); |
54 | compilerParams.ReferencedAssemblies.Add("System.dll"); | 54 | compilerParams.ReferencedAssemblies.Add("System.dll"); |
55 | 55 | ||
56 | compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename); | 56 | compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename); |
57 | 57 | ||
58 | if (compilerResults.Errors.Count > 0) | 58 | if (compilerResults.Errors.Count > 0) |
59 | { | 59 | { |
60 | MainLog.Instance.Error("Compile errors"); | 60 | MainLog.Instance.Error("Compile errors"); |
61 | foreach (CompilerError error in compilerResults.Errors) | 61 | foreach (CompilerError error in compilerResults.Errors) |
62 | { | 62 | { |
63 | MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString()); | 63 | MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString()); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | else | 66 | else |
67 | { | 67 | { |
68 | Dictionary<string,IScript> scripts = new Dictionary<string,IScript>(); | 68 | Dictionary<string,IScript> scripts = new Dictionary<string,IScript>(); |
69 | 69 | ||
70 | foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes()) | 70 | foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes()) |
71 | { | 71 | { |
72 | Type testInterface = pluginType.GetInterface("IScript", true); | 72 | Type testInterface = pluginType.GetInterface("IScript", true); |
73 | 73 | ||
74 | if (testInterface != null) | 74 | if (testInterface != null) |
75 | { | 75 | { |
76 | IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); | 76 | IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); |
77 | 77 | ||
78 | string scriptName = "C#/" + script.getName(); | 78 | string scriptName = "C#/" + script.getName(); |
79 | Console.WriteLine("Script: " + scriptName + " loaded."); | 79 | Console.WriteLine("Script: " + scriptName + " loaded."); |
80 | 80 | ||
81 | if (!scripts.ContainsKey(scriptName)) | 81 | if (!scripts.ContainsKey(scriptName)) |
82 | { | 82 | { |
83 | scripts.Add(scriptName, script); | 83 | scripts.Add(scriptName, script); |
84 | } | 84 | } |
85 | else | 85 | else |
86 | { | 86 | { |
87 | scripts[scriptName] = script; | 87 | scripts[scriptName] = script; |
88 | } | 88 | } |
89 | } | 89 | } |
90 | } | 90 | } |
91 | return scripts; | 91 | return scripts; |
92 | } | 92 | } |
93 | return null; | 93 | return null; |
94 | } | 94 | } |
95 | 95 | ||
96 | public Dictionary<string,IScript> compile(string filename) | 96 | public Dictionary<string,IScript> compile(string filename) |
97 | { | 97 | { |
98 | CSharpCodeProvider csharpProvider = new CSharpCodeProvider(); | 98 | CSharpCodeProvider csharpProvider = new CSharpCodeProvider(); |
99 | return LoadDotNetScript(csharpProvider, filename); | 99 | return LoadDotNetScript(csharpProvider, filename); |
100 | } | 100 | } |
101 | } | 101 | } |
102 | } | 102 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs index d9f1f0a..79d88b1 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs | |||
@@ -1,70 +1,70 @@ | |||
1 | using OpenSim.Framework.Console; | 1 | using OpenSim.Framework.Console; |
2 | using OpenSim.Framework; | 2 | using OpenSim.Framework; |
3 | using OpenSim.Region.Environment; | 3 | using OpenSim.Region.Environment; |
4 | using OpenSim.Region.Environment.Scenes; | 4 | using OpenSim.Region.Environment.Scenes; |
5 | 5 | ||
6 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
7 | using libsecondlife; | 7 | using libsecondlife; |
8 | 8 | ||
9 | namespace OpenSim.Region.Scripting.Examples | 9 | namespace OpenSim.Region.Scripting.Examples |
10 | { | 10 | { |
11 | public class LSLExportScript : IScript | 11 | public class LSLExportScript : IScript |
12 | { | 12 | { |
13 | ScriptInfo script; | 13 | ScriptInfo script; |
14 | 14 | ||
15 | public string getName() | 15 | public string getName() |
16 | { | 16 | { |
17 | return "LSL Export Script 0.1"; | 17 | return "LSL Export Script 0.1"; |
18 | } | 18 | } |
19 | 19 | ||
20 | public void Initialise(ScriptInfo scriptInfo) | 20 | public void Initialise(ScriptInfo scriptInfo) |
21 | { | 21 | { |
22 | script = scriptInfo; | 22 | script = scriptInfo; |
23 | 23 | ||
24 | script.events.OnScriptConsole += new EventManager.OnScriptConsoleDelegate(ProcessConsoleMsg); | 24 | script.events.OnScriptConsole += new EventManager.OnScriptConsoleDelegate(ProcessConsoleMsg); |
25 | } | 25 | } |
26 | 26 | ||
27 | void ProcessConsoleMsg(string[] args) | 27 | void ProcessConsoleMsg(string[] args) |
28 | { | 28 | { |
29 | if (args[0].ToLower() == "lslexport") | 29 | if (args[0].ToLower() == "lslexport") |
30 | { | 30 | { |
31 | string sequence = ""; | 31 | string sequence = ""; |
32 | 32 | ||
33 | foreach (KeyValuePair<LLUUID, SceneObject> obj in script.world.Objects) | 33 | foreach (KeyValuePair<LLUUID, SceneObject> obj in script.world.Objects) |
34 | { | 34 | { |
35 | SceneObject root = obj.Value; | 35 | SceneObject root = obj.Value; |
36 | 36 | ||
37 | sequence += "NEWOBJ::" + obj.Key.ToStringHyphenated() + "\n"; | 37 | sequence += "NEWOBJ::" + obj.Key.ToStringHyphenated() + "\n"; |
38 | 38 | ||
39 | string rootPrim = processPrimitiveToString(root.rootPrimitive); | 39 | string rootPrim = processPrimitiveToString(root.rootPrimitive); |
40 | 40 | ||
41 | sequence += "ROOT:" + rootPrim; | 41 | sequence += "ROOT:" + rootPrim; |
42 | 42 | ||
43 | foreach (KeyValuePair<LLUUID, OpenSim.Region.Environment.Scenes.Primitive> prim in root.Children) | 43 | foreach (KeyValuePair<LLUUID, OpenSim.Region.Environment.Scenes.Primitive> prim in root.Children) |
44 | { | 44 | { |
45 | string child = processPrimitiveToString(prim.Value); | 45 | string child = processPrimitiveToString(prim.Value); |
46 | sequence += "CHILD:" + child; | 46 | sequence += "CHILD:" + child; |
47 | } | 47 | } |
48 | } | 48 | } |
49 | 49 | ||
50 | System.Console.WriteLine(sequence); | 50 | System.Console.WriteLine(sequence); |
51 | } | 51 | } |
52 | } | 52 | } |
53 | 53 | ||
54 | string processPrimitiveToString(OpenSim.Region.Environment.Scenes.Primitive prim) | 54 | string processPrimitiveToString(OpenSim.Region.Environment.Scenes.Primitive prim) |
55 | { | 55 | { |
56 | string desc = prim.Description; | 56 | string desc = prim.Description; |
57 | string name = prim.Name; | 57 | string name = prim.Name; |
58 | LLVector3 pos = prim.Pos; | 58 | LLVector3 pos = prim.Pos; |
59 | LLVector3 rot = new LLVector3(); | 59 | LLVector3 rot = new LLVector3(); |
60 | LLVector3 scale = prim.Scale; | 60 | LLVector3 scale = prim.Scale; |
61 | LLVector3 rootPos = prim.WorldPos; | 61 | LLVector3 rootPos = prim.WorldPos; |
62 | 62 | ||
63 | string setPrimParams = ""; | 63 | string setPrimParams = ""; |
64 | 64 | ||
65 | setPrimParams += "[PRIM_SCALE, " + scale.ToString() + ", PRIM_POS, " + rootPos.ToString() + ", PRIM_ROTATION, " + rot.ToString() + "]\n"; | 65 | setPrimParams += "[PRIM_SCALE, " + scale.ToString() + ", PRIM_POS, " + rootPos.ToString() + ", PRIM_ROTATION, " + rot.ToString() + "]\n"; |
66 | 66 | ||
67 | return setPrimParams; | 67 | return setPrimParams; |
68 | } | 68 | } |
69 | } | 69 | } |
70 | } \ No newline at end of file | 70 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine/JScriptEngine.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine/JScriptEngine.cs index 0833e7a..af4f8b4 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine/JScriptEngine.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine/JScriptEngine.cs | |||
@@ -1,102 +1,102 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.CodeDom.Compiler; | 29 | using System.CodeDom.Compiler; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using Microsoft.JScript; | 31 | using Microsoft.JScript; |
32 | using OpenSim.Framework.Console; | 32 | using OpenSim.Framework.Console; |
33 | 33 | ||
34 | namespace OpenSim.Region.Scripting | 34 | namespace OpenSim.Region.Scripting |
35 | { | 35 | { |
36 | public class JScriptEngine : IScriptCompiler | 36 | public class JScriptEngine : IScriptCompiler |
37 | { | 37 | { |
38 | public string FileExt() | 38 | public string FileExt() |
39 | { | 39 | { |
40 | return ".js"; | 40 | return ".js"; |
41 | } | 41 | } |
42 | 42 | ||
43 | private Dictionary<string, IScript> LoadDotNetScript(CodeDomProvider compiler, string filename) | 43 | private Dictionary<string, IScript> LoadDotNetScript(CodeDomProvider compiler, string filename) |
44 | { | 44 | { |
45 | CompilerParameters compilerParams = new CompilerParameters(); | 45 | CompilerParameters compilerParams = new CompilerParameters(); |
46 | CompilerResults compilerResults; | 46 | CompilerResults compilerResults; |
47 | compilerParams.GenerateExecutable = false; | 47 | compilerParams.GenerateExecutable = false; |
48 | compilerParams.GenerateInMemory = true; | 48 | compilerParams.GenerateInMemory = true; |
49 | compilerParams.IncludeDebugInformation = false; | 49 | compilerParams.IncludeDebugInformation = false; |
50 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll"); | 50 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll"); |
51 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll"); | 51 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll"); |
52 | compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll"); | 52 | compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll"); |
53 | compilerParams.ReferencedAssemblies.Add("libsecondlife.dll"); | 53 | compilerParams.ReferencedAssemblies.Add("libsecondlife.dll"); |
54 | compilerParams.ReferencedAssemblies.Add("System.dll"); | 54 | compilerParams.ReferencedAssemblies.Add("System.dll"); |
55 | 55 | ||
56 | compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename); | 56 | compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename); |
57 | 57 | ||
58 | if (compilerResults.Errors.Count > 0) | 58 | if (compilerResults.Errors.Count > 0) |
59 | { | 59 | { |
60 | MainLog.Instance.Error("Compile errors"); | 60 | MainLog.Instance.Error("Compile errors"); |
61 | foreach (CompilerError error in compilerResults.Errors) | 61 | foreach (CompilerError error in compilerResults.Errors) |
62 | { | 62 | { |
63 | MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString()); | 63 | MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString()); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | else | 66 | else |
67 | { | 67 | { |
68 | Dictionary<string, IScript> scripts = new Dictionary<string, IScript>(); | 68 | Dictionary<string, IScript> scripts = new Dictionary<string, IScript>(); |
69 | 69 | ||
70 | foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes()) | 70 | foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes()) |
71 | { | 71 | { |
72 | Type testInterface = pluginType.GetInterface("IScript", true); | 72 | Type testInterface = pluginType.GetInterface("IScript", true); |
73 | 73 | ||
74 | if (testInterface != null) | 74 | if (testInterface != null) |
75 | { | 75 | { |
76 | IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); | 76 | IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); |
77 | 77 | ||
78 | string scriptName = "JS.NET/" + script.getName(); | 78 | string scriptName = "JS.NET/" + script.getName(); |
79 | Console.WriteLine("Script: " + scriptName + " loaded."); | 79 | Console.WriteLine("Script: " + scriptName + " loaded."); |
80 | 80 | ||
81 | if (!scripts.ContainsKey(scriptName)) | 81 | if (!scripts.ContainsKey(scriptName)) |
82 | { | 82 | { |
83 | scripts.Add(scriptName, script); | 83 | scripts.Add(scriptName, script); |
84 | } | 84 | } |
85 | else | 85 | else |
86 | { | 86 | { |
87 | scripts[scriptName] = script; | 87 | scripts[scriptName] = script; |
88 | } | 88 | } |
89 | } | 89 | } |
90 | } | 90 | } |
91 | return scripts; | 91 | return scripts; |
92 | } | 92 | } |
93 | return null; | 93 | return null; |
94 | } | 94 | } |
95 | 95 | ||
96 | public Dictionary<string, IScript> compile(string filename) | 96 | public Dictionary<string, IScript> compile(string filename) |
97 | { | 97 | { |
98 | JScriptCodeProvider jscriptProvider = new JScriptCodeProvider(); | 98 | JScriptCodeProvider jscriptProvider = new JScriptCodeProvider(); |
99 | return LoadDotNetScript(jscriptProvider, filename); | 99 | return LoadDotNetScript(jscriptProvider, filename); |
100 | } | 100 | } |
101 | } | 101 | } |
102 | } | 102 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassInstance.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassInstance.cs index 0b1cf41..ca729b4 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassInstance.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassInstance.cs | |||
@@ -1,45 +1,45 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | using OpenSim.Region.Scripting.EmbeddedJVM.Types; | 31 | using OpenSim.Region.Scripting.EmbeddedJVM.Types; |
32 | 32 | ||
33 | namespace OpenSim.Region.Scripting.EmbeddedJVM | 33 | namespace OpenSim.Region.Scripting.EmbeddedJVM |
34 | { | 34 | { |
35 | public class ClassInstance : Object | 35 | public class ClassInstance : Object |
36 | { | 36 | { |
37 | public int size; | 37 | public int size; |
38 | public Dictionary<string, BaseType> Fields = new Dictionary<string, BaseType>(); | 38 | public Dictionary<string, BaseType> Fields = new Dictionary<string, BaseType>(); |
39 | 39 | ||
40 | public ClassInstance() | 40 | public ClassInstance() |
41 | { | 41 | { |
42 | 42 | ||
43 | } | 43 | } |
44 | } | 44 | } |
45 | } | 45 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassRecord.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassRecord.cs index f821f52..f151b7e 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassRecord.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/ClassRecord.cs | |||
@@ -1,503 +1,503 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Text; | 31 | using System.Text; |
32 | using OpenSim.Region.Scripting.EmbeddedJVM.Types; | 32 | using OpenSim.Region.Scripting.EmbeddedJVM.Types; |
33 | 33 | ||
34 | namespace OpenSim.Region.Scripting.EmbeddedJVM | 34 | namespace OpenSim.Region.Scripting.EmbeddedJVM |
35 | { | 35 | { |
36 | public class ClassRecord | 36 | public class ClassRecord |
37 | { | 37 | { |
38 | private ushort _majorVersion; | 38 | private ushort _majorVersion; |
39 | private ushort _minorVersion; | 39 | private ushort _minorVersion; |
40 | private ushort _constantPoolCount; | 40 | private ushort _constantPoolCount; |
41 | private ushort _accessFlags; | 41 | private ushort _accessFlags; |
42 | private ushort _thisClass; | 42 | private ushort _thisClass; |
43 | private ushort _supperClass; | 43 | private ushort _supperClass; |
44 | private ushort _interfaceCount; | 44 | private ushort _interfaceCount; |
45 | private ushort _fieldCount; | 45 | private ushort _fieldCount; |
46 | private ushort _methodCount; | 46 | private ushort _methodCount; |
47 | //private ushort _attributeCount; | 47 | //private ushort _attributeCount; |
48 | //private string _name; | 48 | //private string _name; |
49 | public Dictionary<string, BaseType> StaticFields = new Dictionary<string, BaseType>(); | 49 | public Dictionary<string, BaseType> StaticFields = new Dictionary<string, BaseType>(); |
50 | public PoolClass mClass; | 50 | public PoolClass mClass; |
51 | 51 | ||
52 | public List<PoolItem> _constantsPool = new List<PoolItem>(); | 52 | public List<PoolItem> _constantsPool = new List<PoolItem>(); |
53 | private List<MethodInfo> _methodsList = new List<MethodInfo>(); | 53 | private List<MethodInfo> _methodsList = new List<MethodInfo>(); |
54 | private List<FieldInfo> _fieldList = new List<FieldInfo>(); | 54 | private List<FieldInfo> _fieldList = new List<FieldInfo>(); |
55 | 55 | ||
56 | public ClassRecord() | 56 | public ClassRecord() |
57 | { | 57 | { |
58 | 58 | ||
59 | } | 59 | } |
60 | 60 | ||
61 | public ClassInstance CreateNewInstance() | 61 | public ClassInstance CreateNewInstance() |
62 | { | 62 | { |
63 | return new ClassInstance(); | 63 | return new ClassInstance(); |
64 | } | 64 | } |
65 | 65 | ||
66 | public void LoadClassFromFile(string fileName) | 66 | public void LoadClassFromFile(string fileName) |
67 | { | 67 | { |
68 | Console.WriteLine("loading script " + fileName); | 68 | Console.WriteLine("loading script " + fileName); |
69 | FileStream fs = File.OpenRead(fileName); | 69 | FileStream fs = File.OpenRead(fileName); |
70 | this.LoadClassFromBytes(ReadFully(fs)); | 70 | this.LoadClassFromBytes(ReadFully(fs)); |
71 | fs.Close(); | 71 | fs.Close(); |
72 | } | 72 | } |
73 | 73 | ||
74 | public void LoadClassFromBytes(byte[] data) | 74 | public void LoadClassFromBytes(byte[] data) |
75 | { | 75 | { |
76 | int i = 0; | 76 | int i = 0; |
77 | i += 4; | 77 | i += 4; |
78 | _minorVersion = (ushort)((data[i++] << 8) + data[i++] ); | 78 | _minorVersion = (ushort)((data[i++] << 8) + data[i++] ); |
79 | _majorVersion = (ushort)((data[i++] << 8) + data[i++] ); | 79 | _majorVersion = (ushort)((data[i++] << 8) + data[i++] ); |
80 | _constantPoolCount = (ushort)((data[i++] << 8) + data[i++] ); | 80 | _constantPoolCount = (ushort)((data[i++] << 8) + data[i++] ); |
81 | // Console.WriteLine("there should be " + _constantPoolCount + " items in the pool"); | 81 | // Console.WriteLine("there should be " + _constantPoolCount + " items in the pool"); |
82 | for (int count = 0; count < _constantPoolCount -1 ; count++) | 82 | for (int count = 0; count < _constantPoolCount -1 ; count++) |
83 | { | 83 | { |
84 | //read in the constant pool | 84 | //read in the constant pool |
85 | byte pooltype = data[i++]; | 85 | byte pooltype = data[i++]; |
86 | //Console.WriteLine("#" +count +": new constant type = " +pooltype); | 86 | //Console.WriteLine("#" +count +": new constant type = " +pooltype); |
87 | //Console.WriteLine("start position is: " + i); | 87 | //Console.WriteLine("start position is: " + i); |
88 | switch (pooltype) | 88 | switch (pooltype) |
89 | { | 89 | { |
90 | case 1: //Utf8 | 90 | case 1: //Utf8 |
91 | ushort uLength = (ushort)((data[i++] << 8) + data[i++] ); | 91 | ushort uLength = (ushort)((data[i++] << 8) + data[i++] ); |
92 | 92 | ||
93 | // Console.WriteLine("new utf8 type, length is " + uLength); | 93 | // Console.WriteLine("new utf8 type, length is " + uLength); |
94 | PoolUtf8 utf8 = new PoolUtf8(); | 94 | PoolUtf8 utf8 = new PoolUtf8(); |
95 | utf8.readValue(data, ref i, uLength); | 95 | utf8.readValue(data, ref i, uLength); |
96 | this._constantsPool.Add(utf8); | 96 | this._constantsPool.Add(utf8); |
97 | break; | 97 | break; |
98 | case 3: //Int | 98 | case 3: //Int |
99 | break; | 99 | break; |
100 | case 7: //Class | 100 | case 7: //Class |
101 | PoolClass pClass = new PoolClass(this); | 101 | PoolClass pClass = new PoolClass(this); |
102 | pClass.readValue(data, ref i); | 102 | pClass.readValue(data, ref i); |
103 | this._constantsPool.Add(pClass); | 103 | this._constantsPool.Add(pClass); |
104 | break; | 104 | break; |
105 | case 10: //Method | 105 | case 10: //Method |
106 | PoolMethodRef pMeth = new PoolMethodRef(this); | 106 | PoolMethodRef pMeth = new PoolMethodRef(this); |
107 | pMeth.readValue(data, ref i); | 107 | pMeth.readValue(data, ref i); |
108 | this._constantsPool.Add(pMeth); | 108 | this._constantsPool.Add(pMeth); |
109 | break; | 109 | break; |
110 | case 12: //NamedType | 110 | case 12: //NamedType |
111 | PoolNamedType pNamed = new PoolNamedType(this); | 111 | PoolNamedType pNamed = new PoolNamedType(this); |
112 | pNamed.readValue(data, ref i); | 112 | pNamed.readValue(data, ref i); |
113 | this._constantsPool.Add(pNamed); | 113 | this._constantsPool.Add(pNamed); |
114 | break; | 114 | break; |
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
118 | _accessFlags = (ushort)((data[i++] << 8) + data[i++] ); | 118 | _accessFlags = (ushort)((data[i++] << 8) + data[i++] ); |
119 | _thisClass = (ushort)((data[i++] << 8) + data[i++] ); | 119 | _thisClass = (ushort)((data[i++] << 8) + data[i++] ); |
120 | _supperClass = (ushort)((data[i++] << 8) + data[i++] ); | 120 | _supperClass = (ushort)((data[i++] << 8) + data[i++] ); |
121 | 121 | ||
122 | if (this._constantsPool[this._thisClass - 1] is PoolClass) | 122 | if (this._constantsPool[this._thisClass - 1] is PoolClass) |
123 | { | 123 | { |
124 | this.mClass = ((PoolClass)this._constantsPool[this._thisClass - 1]); | 124 | this.mClass = ((PoolClass)this._constantsPool[this._thisClass - 1]); |
125 | } | 125 | } |
126 | 126 | ||
127 | _interfaceCount = (ushort)((data[i++] << 8) + data[i++]); | 127 | _interfaceCount = (ushort)((data[i++] << 8) + data[i++]); |
128 | //should now read in the info for each interface | 128 | //should now read in the info for each interface |
129 | _fieldCount = (ushort)((data[i++] << 8) + data[i++]); | 129 | _fieldCount = (ushort)((data[i++] << 8) + data[i++]); |
130 | //should now read in the info for each field | 130 | //should now read in the info for each field |
131 | _methodCount = (ushort)((data[i++] << 8) + data[i++]); | 131 | _methodCount = (ushort)((data[i++] << 8) + data[i++]); |
132 | for (int count = 0; count < _methodCount; count++) | 132 | for (int count = 0; count < _methodCount; count++) |
133 | { | 133 | { |
134 | MethodInfo methInf = new MethodInfo(this); | 134 | MethodInfo methInf = new MethodInfo(this); |
135 | methInf.ReadData(data, ref i); | 135 | methInf.ReadData(data, ref i); |
136 | this._methodsList.Add(methInf); | 136 | this._methodsList.Add(methInf); |
137 | } | 137 | } |
138 | } | 138 | } |
139 | 139 | ||
140 | public void AddMethodsToMemory(MethodMemory memory) | 140 | public void AddMethodsToMemory(MethodMemory memory) |
141 | { | 141 | { |
142 | for (int count = 0; count < _methodCount; count++) | 142 | for (int count = 0; count < _methodCount; count++) |
143 | { | 143 | { |
144 | this._methodsList[count].AddMethodCode(memory); | 144 | this._methodsList[count].AddMethodCode(memory); |
145 | } | 145 | } |
146 | } | 146 | } |
147 | 147 | ||
148 | public bool StartMethod(Thread thread, string methodName) | 148 | public bool StartMethod(Thread thread, string methodName) |
149 | { | 149 | { |
150 | for (int count = 0; count < _methodCount; count++) | 150 | for (int count = 0; count < _methodCount; count++) |
151 | { | 151 | { |
152 | if (this._constantsPool[this._methodsList[count].NameIndex-1] is PoolUtf8) | 152 | if (this._constantsPool[this._methodsList[count].NameIndex-1] is PoolUtf8) |
153 | { | 153 | { |
154 | if (((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex-1]).Value == methodName) | 154 | if (((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex-1]).Value == methodName) |
155 | { | 155 | { |
156 | //Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value); | 156 | //Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value); |
157 | thread.SetPC(this._methodsList[count].CodePointer); | 157 | thread.SetPC(this._methodsList[count].CodePointer); |
158 | return true; | 158 | return true; |
159 | } | 159 | } |
160 | } | 160 | } |
161 | } | 161 | } |
162 | return false; | 162 | return false; |
163 | } | 163 | } |
164 | 164 | ||
165 | public void PrintToConsole() | 165 | public void PrintToConsole() |
166 | { | 166 | { |
167 | Console.WriteLine("Class File:"); | 167 | Console.WriteLine("Class File:"); |
168 | Console.WriteLine("Major version: " + _majorVersion); | 168 | Console.WriteLine("Major version: " + _majorVersion); |
169 | Console.WriteLine("Minor version: " + _minorVersion); | 169 | Console.WriteLine("Minor version: " + _minorVersion); |
170 | Console.WriteLine("Pool size: " + _constantPoolCount); | 170 | Console.WriteLine("Pool size: " + _constantPoolCount); |
171 | 171 | ||
172 | for (int i = 0; i < _constantsPool.Count; i++) | 172 | for (int i = 0; i < _constantsPool.Count; i++) |
173 | { | 173 | { |
174 | this._constantsPool[i].Print(); | 174 | this._constantsPool[i].Print(); |
175 | } | 175 | } |
176 | 176 | ||
177 | Console.WriteLine("Access flags: " + _accessFlags); | 177 | Console.WriteLine("Access flags: " + _accessFlags); |
178 | Console.WriteLine("This class: " + _thisClass ); | 178 | Console.WriteLine("This class: " + _thisClass ); |
179 | Console.WriteLine("Super class: " + _supperClass); | 179 | Console.WriteLine("Super class: " + _supperClass); |
180 | 180 | ||
181 | for (int count = 0; count < _methodCount; count++) | 181 | for (int count = 0; count < _methodCount; count++) |
182 | { | 182 | { |
183 | Console.WriteLine(); | 183 | Console.WriteLine(); |
184 | this._methodsList[count].Print(); | 184 | this._methodsList[count].Print(); |
185 | } | 185 | } |
186 | 186 | ||
187 | Console.WriteLine("class name is " + this.mClass.Name.Value); | 187 | Console.WriteLine("class name is " + this.mClass.Name.Value); |
188 | } | 188 | } |
189 | 189 | ||
190 | public static byte[] ReadFully(Stream stream) | 190 | public static byte[] ReadFully(Stream stream) |
191 | { | 191 | { |
192 | byte[] buffer = new byte[1024]; | 192 | byte[] buffer = new byte[1024]; |
193 | using (MemoryStream ms = new MemoryStream()) | 193 | using (MemoryStream ms = new MemoryStream()) |
194 | { | 194 | { |
195 | while (true) | 195 | while (true) |
196 | { | 196 | { |
197 | int read = stream.Read(buffer, 0, buffer.Length); | 197 | int read = stream.Read(buffer, 0, buffer.Length); |
198 | if (read <= 0) | 198 | if (read <= 0) |
199 | return ms.ToArray(); | 199 | return ms.ToArray(); |
200 | ms.Write(buffer, 0, read); | 200 | ms.Write(buffer, 0, read); |
201 | } | 201 | } |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | #region nested classes | 205 | #region nested classes |
206 | public class PoolItem | 206 | public class PoolItem |
207 | { | 207 | { |
208 | public virtual void Print() | 208 | public virtual void Print() |
209 | { | 209 | { |
210 | 210 | ||
211 | } | 211 | } |
212 | } | 212 | } |
213 | 213 | ||
214 | public class PoolUtf8 : PoolItem | 214 | public class PoolUtf8 : PoolItem |
215 | { | 215 | { |
216 | public string Value = ""; | 216 | public string Value = ""; |
217 | 217 | ||
218 | public void readValue(byte[] data,ref int pointer , int length) | 218 | public void readValue(byte[] data,ref int pointer , int length) |
219 | { | 219 | { |
220 | for (int i = 0; i < length; i++) | 220 | for (int i = 0; i < length; i++) |
221 | { | 221 | { |
222 | int a =(int) data[pointer++]; | 222 | int a =(int) data[pointer++]; |
223 | if ((a & 0x80) == 0) | 223 | if ((a & 0x80) == 0) |
224 | { | 224 | { |
225 | Value = Value + (char)a; | 225 | Value = Value + (char)a; |
226 | } | 226 | } |
227 | else if ((a & 0x20) == 0) | 227 | else if ((a & 0x20) == 0) |
228 | { | 228 | { |
229 | int b = (int) data[pointer++]; | 229 | int b = (int) data[pointer++]; |
230 | Value = Value + (char)(((a & 0x1f) << 6) + (b & 0x3f)); | 230 | Value = Value + (char)(((a & 0x1f) << 6) + (b & 0x3f)); |
231 | } | 231 | } |
232 | else | 232 | else |
233 | { | 233 | { |
234 | int b = (int)data[pointer++]; | 234 | int b = (int)data[pointer++]; |
235 | int c = (int)data[pointer++]; | 235 | int c = (int)data[pointer++]; |
236 | Value = Value + (char)(((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f)); | 236 | Value = Value + (char)(((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f)); |
237 | } | 237 | } |
238 | } | 238 | } |
239 | } | 239 | } |
240 | 240 | ||
241 | public override void Print() | 241 | public override void Print() |
242 | { | 242 | { |
243 | Console.WriteLine("Utf8 type: " + Value); | 243 | Console.WriteLine("Utf8 type: " + Value); |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | private class PoolInt : PoolItem | 247 | private class PoolInt : PoolItem |
248 | { | 248 | { |
249 | 249 | ||
250 | } | 250 | } |
251 | 251 | ||
252 | public class PoolClass : PoolItem | 252 | public class PoolClass : PoolItem |
253 | { | 253 | { |
254 | //public string name = ""; | 254 | //public string name = ""; |
255 | public ushort namePointer = 0; | 255 | public ushort namePointer = 0; |
256 | private ClassRecord parent; | 256 | private ClassRecord parent; |
257 | public PoolUtf8 Name; | 257 | public PoolUtf8 Name; |
258 | 258 | ||
259 | public PoolClass(ClassRecord paren) | 259 | public PoolClass(ClassRecord paren) |
260 | { | 260 | { |
261 | parent = paren; | 261 | parent = paren; |
262 | } | 262 | } |
263 | 263 | ||
264 | public void readValue(byte[] data, ref int pointer) | 264 | public void readValue(byte[] data, ref int pointer) |
265 | { | 265 | { |
266 | namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); | 266 | namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); |
267 | } | 267 | } |
268 | 268 | ||
269 | public override void Print() | 269 | public override void Print() |
270 | { | 270 | { |
271 | this.Name = ((PoolUtf8)this.parent._constantsPool[namePointer - 1]); | 271 | this.Name = ((PoolUtf8)this.parent._constantsPool[namePointer - 1]); |
272 | Console.Write("Class type: " + namePointer); | 272 | Console.Write("Class type: " + namePointer); |
273 | Console.WriteLine(" // " + ((PoolUtf8)this.parent._constantsPool[namePointer - 1]).Value); | 273 | Console.WriteLine(" // " + ((PoolUtf8)this.parent._constantsPool[namePointer - 1]).Value); |
274 | 274 | ||
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | public class PoolMethodRef : PoolItem | 278 | public class PoolMethodRef : PoolItem |
279 | { | 279 | { |
280 | public ushort classPointer = 0; | 280 | public ushort classPointer = 0; |
281 | public ushort nameTypePointer = 0; | 281 | public ushort nameTypePointer = 0; |
282 | public PoolNamedType mNameType; | 282 | public PoolNamedType mNameType; |
283 | public PoolClass mClass; | 283 | public PoolClass mClass; |
284 | private ClassRecord parent; | 284 | private ClassRecord parent; |
285 | 285 | ||
286 | public PoolMethodRef(ClassRecord paren) | 286 | public PoolMethodRef(ClassRecord paren) |
287 | { | 287 | { |
288 | parent = paren; | 288 | parent = paren; |
289 | } | 289 | } |
290 | 290 | ||
291 | public void readValue(byte[] data, ref int pointer) | 291 | public void readValue(byte[] data, ref int pointer) |
292 | { | 292 | { |
293 | classPointer = (ushort)((data[pointer++] << 8) + data[pointer++]); | 293 | classPointer = (ushort)((data[pointer++] << 8) + data[pointer++]); |
294 | nameTypePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); | 294 | nameTypePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); |
295 | } | 295 | } |
296 | 296 | ||
297 | public override void Print() | 297 | public override void Print() |
298 | { | 298 | { |
299 | this.mNameType = ((PoolNamedType)this.parent._constantsPool[nameTypePointer - 1]); | 299 | this.mNameType = ((PoolNamedType)this.parent._constantsPool[nameTypePointer - 1]); |
300 | this.mClass = ((PoolClass)this.parent._constantsPool[classPointer - 1]); | 300 | this.mClass = ((PoolClass)this.parent._constantsPool[classPointer - 1]); |
301 | Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer); | 301 | Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer); |
302 | } | 302 | } |
303 | } | 303 | } |
304 | 304 | ||
305 | public class PoolNamedType : PoolItem | 305 | public class PoolNamedType : PoolItem |
306 | { | 306 | { |
307 | public ushort namePointer = 0; | 307 | public ushort namePointer = 0; |
308 | public ushort typePointer = 0; | 308 | public ushort typePointer = 0; |
309 | private ClassRecord parent; | 309 | private ClassRecord parent; |
310 | public PoolUtf8 Name; | 310 | public PoolUtf8 Name; |
311 | public PoolUtf8 Type; | 311 | public PoolUtf8 Type; |
312 | 312 | ||
313 | public PoolNamedType(ClassRecord paren) | 313 | public PoolNamedType(ClassRecord paren) |
314 | { | 314 | { |
315 | parent = paren; | 315 | parent = paren; |
316 | } | 316 | } |
317 | 317 | ||
318 | public void readValue(byte[] data, ref int pointer) | 318 | public void readValue(byte[] data, ref int pointer) |
319 | { | 319 | { |
320 | namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); | 320 | namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); |
321 | typePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); | 321 | typePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); |
322 | } | 322 | } |
323 | 323 | ||
324 | public override void Print() | 324 | public override void Print() |
325 | { | 325 | { |
326 | Name = ((PoolUtf8)this.parent._constantsPool[namePointer-1]); | 326 | Name = ((PoolUtf8)this.parent._constantsPool[namePointer-1]); |
327 | Type = ((PoolUtf8)this.parent._constantsPool[typePointer-1]); | 327 | Type = ((PoolUtf8)this.parent._constantsPool[typePointer-1]); |
328 | Console.Write("Named type: " + namePointer + " , " + typePointer ); | 328 | Console.Write("Named type: " + namePointer + " , " + typePointer ); |
329 | Console.WriteLine(" // "+ ((PoolUtf8)this.parent._constantsPool[namePointer-1]).Value); | 329 | Console.WriteLine(" // "+ ((PoolUtf8)this.parent._constantsPool[namePointer-1]).Value); |
330 | } | 330 | } |
331 | } | 331 | } |
332 | 332 | ||
333 | //*********************** | 333 | //*********************** |
334 | public class MethodInfo | 334 | public class MethodInfo |
335 | { | 335 | { |
336 | public ushort AccessFlags = 0; | 336 | public ushort AccessFlags = 0; |
337 | public ushort NameIndex = 0; | 337 | public ushort NameIndex = 0; |
338 | public string Name = ""; | 338 | public string Name = ""; |
339 | public ushort DescriptorIndex = 0; | 339 | public ushort DescriptorIndex = 0; |
340 | public ushort AttributeCount = 0; | 340 | public ushort AttributeCount = 0; |
341 | public List<MethodAttribute> Attributes = new List<MethodAttribute>(); | 341 | public List<MethodAttribute> Attributes = new List<MethodAttribute>(); |
342 | private ClassRecord parent; | 342 | private ClassRecord parent; |
343 | public int CodePointer = 0; | 343 | public int CodePointer = 0; |
344 | 344 | ||
345 | public MethodInfo(ClassRecord paren) | 345 | public MethodInfo(ClassRecord paren) |
346 | { | 346 | { |
347 | parent = paren; | 347 | parent = paren; |
348 | } | 348 | } |
349 | 349 | ||
350 | public void AddMethodCode(MethodMemory memory) | 350 | public void AddMethodCode(MethodMemory memory) |
351 | { | 351 | { |
352 | Array.Copy(this.Attributes[0].Code, 0, memory.MethodBuffer, memory.NextMethodPC, this.Attributes[0].Code.Length); | 352 | Array.Copy(this.Attributes[0].Code, 0, memory.MethodBuffer, memory.NextMethodPC, this.Attributes[0].Code.Length); |
353 | memory.Methodcount++; | 353 | memory.Methodcount++; |
354 | this.CodePointer = memory.NextMethodPC; | 354 | this.CodePointer = memory.NextMethodPC; |
355 | memory.NextMethodPC += this.Attributes[0].Code.Length; | 355 | memory.NextMethodPC += this.Attributes[0].Code.Length; |
356 | } | 356 | } |
357 | 357 | ||
358 | public void ReadData(byte[] data, ref int pointer) | 358 | public void ReadData(byte[] data, ref int pointer) |
359 | { | 359 | { |
360 | AccessFlags = (ushort)((data[pointer++] << 8) + data[pointer++]); | 360 | AccessFlags = (ushort)((data[pointer++] << 8) + data[pointer++]); |
361 | NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); | 361 | NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); |
362 | DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); | 362 | DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); |
363 | AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); | 363 | AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); |
364 | for(int i =0; i< AttributeCount; i++) | 364 | for(int i =0; i< AttributeCount; i++) |
365 | { | 365 | { |
366 | MethodAttribute attri = new MethodAttribute(this.parent); | 366 | MethodAttribute attri = new MethodAttribute(this.parent); |
367 | attri.ReadData(data, ref pointer); | 367 | attri.ReadData(data, ref pointer); |
368 | this.Attributes.Add(attri); | 368 | this.Attributes.Add(attri); |
369 | } | 369 | } |
370 | } | 370 | } |
371 | 371 | ||
372 | public void Print() | 372 | public void Print() |
373 | { | 373 | { |
374 | Console.WriteLine("Method Info Struct: "); | 374 | Console.WriteLine("Method Info Struct: "); |
375 | Console.WriteLine("AccessFlags: " + AccessFlags); | 375 | Console.WriteLine("AccessFlags: " + AccessFlags); |
376 | Console.WriteLine("NameIndex: " + NameIndex +" // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value); | 376 | Console.WriteLine("NameIndex: " + NameIndex +" // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value); |
377 | Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[DescriptorIndex-1]).Value); | 377 | Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[DescriptorIndex-1]).Value); |
378 | Console.WriteLine("Attribute Count:" + AttributeCount); | 378 | Console.WriteLine("Attribute Count:" + AttributeCount); |
379 | for (int i = 0; i < AttributeCount; i++) | 379 | for (int i = 0; i < AttributeCount; i++) |
380 | { | 380 | { |
381 | this.Attributes[i].Print(); | 381 | this.Attributes[i].Print(); |
382 | } | 382 | } |
383 | } | 383 | } |
384 | 384 | ||
385 | public class MethodAttribute | 385 | public class MethodAttribute |
386 | { | 386 | { |
387 | public ushort NameIndex = 0; | 387 | public ushort NameIndex = 0; |
388 | public string Name = ""; | 388 | public string Name = ""; |
389 | public Int32 Length = 0; | 389 | public Int32 Length = 0; |
390 | //for now only support code attribute | 390 | //for now only support code attribute |
391 | public ushort MaxStack = 0; | 391 | public ushort MaxStack = 0; |
392 | public ushort MaxLocals = 0; | 392 | public ushort MaxLocals = 0; |
393 | public Int32 CodeLength = 0; | 393 | public Int32 CodeLength = 0; |
394 | public byte[] Code; | 394 | public byte[] Code; |
395 | public ushort ExceptionTableLength = 0; | 395 | public ushort ExceptionTableLength = 0; |
396 | public ushort SubAttributeCount = 0; | 396 | public ushort SubAttributeCount = 0; |
397 | public List<SubAttribute> SubAttributes = new List<SubAttribute>(); | 397 | public List<SubAttribute> SubAttributes = new List<SubAttribute>(); |
398 | private ClassRecord parent; | 398 | private ClassRecord parent; |
399 | 399 | ||
400 | public MethodAttribute(ClassRecord paren) | 400 | public MethodAttribute(ClassRecord paren) |
401 | { | 401 | { |
402 | parent = paren; | 402 | parent = paren; |
403 | } | 403 | } |
404 | 404 | ||
405 | public void ReadData(byte[] data, ref int pointer) | 405 | public void ReadData(byte[] data, ref int pointer) |
406 | { | 406 | { |
407 | NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); | 407 | NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); |
408 | Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); | 408 | Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); |
409 | MaxStack = (ushort)((data[pointer++] << 8) + data[pointer++]); | 409 | MaxStack = (ushort)((data[pointer++] << 8) + data[pointer++]); |
410 | MaxLocals = (ushort)((data[pointer++] << 8) + data[pointer++]); | 410 | MaxLocals = (ushort)((data[pointer++] << 8) + data[pointer++]); |
411 | CodeLength = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); | 411 | CodeLength = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); |
412 | Code = new byte[CodeLength]; | 412 | Code = new byte[CodeLength]; |
413 | for (int i = 0; i < CodeLength; i++) | 413 | for (int i = 0; i < CodeLength; i++) |
414 | { | 414 | { |
415 | Code[i] = data[pointer++]; | 415 | Code[i] = data[pointer++]; |
416 | } | 416 | } |
417 | ExceptionTableLength = (ushort)((data[pointer++] << 8) + data[pointer++]); | 417 | ExceptionTableLength = (ushort)((data[pointer++] << 8) + data[pointer++]); |
418 | SubAttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); | 418 | SubAttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); |
419 | for (int i = 0; i < SubAttributeCount; i++) | 419 | for (int i = 0; i < SubAttributeCount; i++) |
420 | { | 420 | { |
421 | SubAttribute subAttri = new SubAttribute(this.parent); | 421 | SubAttribute subAttri = new SubAttribute(this.parent); |
422 | subAttri.ReadData(data, ref pointer); | 422 | subAttri.ReadData(data, ref pointer); |
423 | this.SubAttributes.Add(subAttri); | 423 | this.SubAttributes.Add(subAttri); |
424 | } | 424 | } |
425 | } | 425 | } |
426 | 426 | ||
427 | public void Print() | 427 | public void Print() |
428 | { | 428 | { |
429 | Console.WriteLine("Method Attribute: "); | 429 | Console.WriteLine("Method Attribute: "); |
430 | Console.WriteLine("Name Index: " + NameIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value); | 430 | Console.WriteLine("Name Index: " + NameIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value); |
431 | Console.WriteLine("Length: " + Length); | 431 | Console.WriteLine("Length: " + Length); |
432 | Console.WriteLine("MaxStack: " + MaxStack); | 432 | Console.WriteLine("MaxStack: " + MaxStack); |
433 | Console.WriteLine("MaxLocals: " + MaxLocals); | 433 | Console.WriteLine("MaxLocals: " + MaxLocals); |
434 | Console.WriteLine("CodeLength: " + CodeLength); | 434 | Console.WriteLine("CodeLength: " + CodeLength); |
435 | for (int i = 0; i < Code.Length; i++) | 435 | for (int i = 0; i < Code.Length; i++) |
436 | { | 436 | { |
437 | Console.WriteLine("OpCode #" + i + " is: " + Code[i]); | 437 | Console.WriteLine("OpCode #" + i + " is: " + Code[i]); |
438 | } | 438 | } |
439 | Console.WriteLine("SubAttributes: " + SubAttributeCount); | 439 | Console.WriteLine("SubAttributes: " + SubAttributeCount); |
440 | for (int i = 0; i < SubAttributeCount; i++) | 440 | for (int i = 0; i < SubAttributeCount; i++) |
441 | { | 441 | { |
442 | this.SubAttributes[i].Print(); | 442 | this.SubAttributes[i].Print(); |
443 | } | 443 | } |
444 | } | 444 | } |
445 | 445 | ||
446 | public class SubAttribute | 446 | public class SubAttribute |
447 | { | 447 | { |
448 | public ushort NameIndex = 0; | 448 | public ushort NameIndex = 0; |
449 | public string Name = ""; | 449 | public string Name = ""; |
450 | public Int32 Length = 0; | 450 | public Int32 Length = 0; |
451 | public byte[] Data; | 451 | public byte[] Data; |
452 | private ClassRecord parent; | 452 | private ClassRecord parent; |
453 | 453 | ||
454 | public SubAttribute(ClassRecord paren) | 454 | public SubAttribute(ClassRecord paren) |
455 | { | 455 | { |
456 | parent = paren; | 456 | parent = paren; |
457 | } | 457 | } |
458 | 458 | ||
459 | public void ReadData(byte[] data, ref int pointer) | 459 | public void ReadData(byte[] data, ref int pointer) |
460 | { | 460 | { |
461 | NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); | 461 | NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); |
462 | Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); | 462 | Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); |
463 | Data = new byte[Length]; | 463 | Data = new byte[Length]; |
464 | for (int i = 0; i < Length; i++) | 464 | for (int i = 0; i < Length; i++) |
465 | { | 465 | { |
466 | Data[i] = data[pointer++]; | 466 | Data[i] = data[pointer++]; |
467 | } | 467 | } |
468 | } | 468 | } |
469 | 469 | ||
470 | public void Print() | 470 | public void Print() |
471 | { | 471 | { |
472 | Console.WriteLine("SubAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value); | 472 | Console.WriteLine("SubAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value); |
473 | } | 473 | } |
474 | 474 | ||
475 | } | 475 | } |
476 | } | 476 | } |
477 | 477 | ||
478 | } | 478 | } |
479 | private class InterfaceInfo | 479 | private class InterfaceInfo |
480 | { | 480 | { |
481 | public void ReadData(byte[] data, ref int i) | 481 | public void ReadData(byte[] data, ref int i) |
482 | { | 482 | { |
483 | 483 | ||
484 | } | 484 | } |
485 | } | 485 | } |
486 | private class FieldInfo | 486 | private class FieldInfo |
487 | { | 487 | { |
488 | public void ReadData(byte[] data, ref int i) | 488 | public void ReadData(byte[] data, ref int i) |
489 | { | 489 | { |
490 | 490 | ||
491 | } | 491 | } |
492 | } | 492 | } |
493 | private class AttributeInfo | 493 | private class AttributeInfo |
494 | { | 494 | { |
495 | public void ReadData(byte[] data, ref int i) | 495 | public void ReadData(byte[] data, ref int i) |
496 | { | 496 | { |
497 | 497 | ||
498 | } | 498 | } |
499 | } | 499 | } |
500 | #endregion | 500 | #endregion |
501 | 501 | ||
502 | } | 502 | } |
503 | } | 503 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Heap.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Heap.cs index 1a97b7d..c6423fc 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Heap.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Heap.cs | |||
@@ -1,43 +1,43 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | 31 | ||
32 | namespace OpenSim.Region.Scripting.EmbeddedJVM | 32 | namespace OpenSim.Region.Scripting.EmbeddedJVM |
33 | { | 33 | { |
34 | public class Heap | 34 | public class Heap |
35 | { | 35 | { |
36 | public List<ClassInstance> ClassObjects = new List<ClassInstance>(); | 36 | public List<ClassInstance> ClassObjects = new List<ClassInstance>(); |
37 | 37 | ||
38 | public Heap() | 38 | public Heap() |
39 | { | 39 | { |
40 | 40 | ||
41 | } | 41 | } |
42 | } | 42 | } |
43 | } | 43 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Logic.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Logic.cs index ef6b805..56135d3 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Logic.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Logic.cs | |||
@@ -1,427 +1,427 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | using OpenSim.Region.Scripting.EmbeddedJVM.Types; | 31 | using OpenSim.Region.Scripting.EmbeddedJVM.Types; |
32 | using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes; | 32 | using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes; |
33 | 33 | ||
34 | namespace OpenSim.Region.Scripting.EmbeddedJVM | 34 | namespace OpenSim.Region.Scripting.EmbeddedJVM |
35 | { | 35 | { |
36 | partial class Thread | 36 | partial class Thread |
37 | { | 37 | { |
38 | private partial class Interpreter | 38 | private partial class Interpreter |
39 | { | 39 | { |
40 | private bool IsLogicOpCode(byte opcode) | 40 | private bool IsLogicOpCode(byte opcode) |
41 | { | 41 | { |
42 | bool result = false; | 42 | bool result = false; |
43 | switch (opcode) | 43 | switch (opcode) |
44 | { | 44 | { |
45 | case 2: | 45 | case 2: |
46 | Int m_int= new Int(); | 46 | Int m_int= new Int(); |
47 | m_int.mValue = -1; | 47 | m_int.mValue = -1; |
48 | this._mThread.currentFrame.OpStack.Push(m_int); | 48 | this._mThread.currentFrame.OpStack.Push(m_int); |
49 | result = true; | 49 | result = true; |
50 | break; | 50 | break; |
51 | case 3: | 51 | case 3: |
52 | m_int= new Int(); | 52 | m_int= new Int(); |
53 | m_int.mValue = 0; | 53 | m_int.mValue = 0; |
54 | this._mThread.currentFrame.OpStack.Push(m_int); | 54 | this._mThread.currentFrame.OpStack.Push(m_int); |
55 | result = true; | 55 | result = true; |
56 | break; | 56 | break; |
57 | case 4: | 57 | case 4: |
58 | m_int = new Int(); | 58 | m_int = new Int(); |
59 | m_int.mValue = 1; | 59 | m_int.mValue = 1; |
60 | this._mThread.currentFrame.OpStack.Push(m_int); | 60 | this._mThread.currentFrame.OpStack.Push(m_int); |
61 | result = true; | 61 | result = true; |
62 | break; | 62 | break; |
63 | case 5: | 63 | case 5: |
64 | m_int = new Int(); | 64 | m_int = new Int(); |
65 | m_int.mValue = 2; | 65 | m_int.mValue = 2; |
66 | this._mThread.currentFrame.OpStack.Push(m_int); | 66 | this._mThread.currentFrame.OpStack.Push(m_int); |
67 | result = true; | 67 | result = true; |
68 | break; | 68 | break; |
69 | case 6: | 69 | case 6: |
70 | m_int = new Int(); | 70 | m_int = new Int(); |
71 | m_int.mValue = 3; | 71 | m_int.mValue = 3; |
72 | this._mThread.currentFrame.OpStack.Push(m_int); | 72 | this._mThread.currentFrame.OpStack.Push(m_int); |
73 | break; | 73 | break; |
74 | case 7: | 74 | case 7: |
75 | m_int = new Int(); | 75 | m_int = new Int(); |
76 | m_int.mValue = 4; | 76 | m_int.mValue = 4; |
77 | this._mThread.currentFrame.OpStack.Push(m_int); | 77 | this._mThread.currentFrame.OpStack.Push(m_int); |
78 | result = true; | 78 | result = true; |
79 | break; | 79 | break; |
80 | case 8: | 80 | case 8: |
81 | m_int = new Int(); | 81 | m_int = new Int(); |
82 | m_int.mValue = 5; | 82 | m_int.mValue = 5; |
83 | this._mThread.currentFrame.OpStack.Push(m_int); | 83 | this._mThread.currentFrame.OpStack.Push(m_int); |
84 | result = true; | 84 | result = true; |
85 | break; | 85 | break; |
86 | case 11: | 86 | case 11: |
87 | Float m_float = new Float(); | 87 | Float m_float = new Float(); |
88 | m_float.mValue = 0.0f; | 88 | m_float.mValue = 0.0f; |
89 | this._mThread.currentFrame.OpStack.Push(m_float); | 89 | this._mThread.currentFrame.OpStack.Push(m_float); |
90 | result = true; | 90 | result = true; |
91 | break; | 91 | break; |
92 | case 12: | 92 | case 12: |
93 | m_float = new Float(); | 93 | m_float = new Float(); |
94 | m_float.mValue = 1.0f; | 94 | m_float.mValue = 1.0f; |
95 | this._mThread.currentFrame.OpStack.Push(m_float); | 95 | this._mThread.currentFrame.OpStack.Push(m_float); |
96 | result = true; | 96 | result = true; |
97 | break; | 97 | break; |
98 | case 13: | 98 | case 13: |
99 | m_float = new Float(); | 99 | m_float = new Float(); |
100 | m_float.mValue = 2.0f; | 100 | m_float.mValue = 2.0f; |
101 | this._mThread.currentFrame.OpStack.Push(m_float); | 101 | this._mThread.currentFrame.OpStack.Push(m_float); |
102 | result = true; | 102 | result = true; |
103 | break; | 103 | break; |
104 | case 16: | 104 | case 16: |
105 | int pushvalue = (int)GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]; | 105 | int pushvalue = (int)GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]; |
106 | Int pushInt = new Int(); | 106 | Int pushInt = new Int(); |
107 | pushInt.mValue = pushvalue; | 107 | pushInt.mValue = pushvalue; |
108 | this._mThread.currentFrame.OpStack.Push(pushInt); | 108 | this._mThread.currentFrame.OpStack.Push(pushInt); |
109 | this._mThread.PC++; | 109 | this._mThread.PC++; |
110 | result = true; | 110 | result = true; |
111 | break; | 111 | break; |
112 | case 17: | 112 | case 17: |
113 | short pushvalue2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); | 113 | short pushvalue2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); |
114 | Int pushInt2 = new Int(); | 114 | Int pushInt2 = new Int(); |
115 | pushInt2.mValue = pushvalue2; | 115 | pushInt2.mValue = pushvalue2; |
116 | this._mThread.currentFrame.OpStack.Push(pushInt2); | 116 | this._mThread.currentFrame.OpStack.Push(pushInt2); |
117 | this._mThread.PC += 2; | 117 | this._mThread.PC += 2; |
118 | result = true; | 118 | result = true; |
119 | break; | 119 | break; |
120 | case 23: | 120 | case 23: |
121 | short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC])); | 121 | short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC])); |
122 | Float fload = new Float(); | 122 | Float fload = new Float(); |
123 | if (this._mThread.currentFrame.LocalVariables[findex1] != null) | 123 | if (this._mThread.currentFrame.LocalVariables[findex1] != null) |
124 | { | 124 | { |
125 | if (this._mThread.currentFrame.LocalVariables[findex1] is Float) | 125 | if (this._mThread.currentFrame.LocalVariables[findex1] is Float) |
126 | { | 126 | { |
127 | fload.mValue = ((Float)this._mThread.currentFrame.LocalVariables[findex1]).mValue; | 127 | fload.mValue = ((Float)this._mThread.currentFrame.LocalVariables[findex1]).mValue; |
128 | this._mThread.currentFrame.OpStack.Push(fload); | 128 | this._mThread.currentFrame.OpStack.Push(fload); |
129 | } | 129 | } |
130 | } | 130 | } |
131 | this._mThread.PC++; | 131 | this._mThread.PC++; |
132 | result = true; | 132 | result = true; |
133 | break; | 133 | break; |
134 | case 26: | 134 | case 26: |
135 | if (this._mThread.currentFrame.LocalVariables[0] != null) | 135 | if (this._mThread.currentFrame.LocalVariables[0] != null) |
136 | { | 136 | { |
137 | if (this._mThread.currentFrame.LocalVariables[0] is Int) | 137 | if (this._mThread.currentFrame.LocalVariables[0] is Int) |
138 | { | 138 | { |
139 | Int newInt = new Int(); | 139 | Int newInt = new Int(); |
140 | newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[0]).mValue; | 140 | newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[0]).mValue; |
141 | this._mThread.currentFrame.OpStack.Push(newInt); | 141 | this._mThread.currentFrame.OpStack.Push(newInt); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | result = true; | 144 | result = true; |
145 | break; | 145 | break; |
146 | case 27: | 146 | case 27: |
147 | if (this._mThread.currentFrame.LocalVariables[1] != null) | 147 | if (this._mThread.currentFrame.LocalVariables[1] != null) |
148 | { | 148 | { |
149 | if (this._mThread.currentFrame.LocalVariables[1] is Int) | 149 | if (this._mThread.currentFrame.LocalVariables[1] is Int) |
150 | { | 150 | { |
151 | Int newInt = new Int(); | 151 | Int newInt = new Int(); |
152 | newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[1]).mValue; | 152 | newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[1]).mValue; |
153 | this._mThread.currentFrame.OpStack.Push(newInt); | 153 | this._mThread.currentFrame.OpStack.Push(newInt); |
154 | } | 154 | } |
155 | } | 155 | } |
156 | result = true; | 156 | result = true; |
157 | break; | 157 | break; |
158 | case 34: | 158 | case 34: |
159 | if (this._mThread.currentFrame.LocalVariables[0] != null) | 159 | if (this._mThread.currentFrame.LocalVariables[0] != null) |
160 | { | 160 | { |
161 | if (this._mThread.currentFrame.LocalVariables[0] is Float) | 161 | if (this._mThread.currentFrame.LocalVariables[0] is Float) |
162 | { | 162 | { |
163 | Float newfloat = new Float(); | 163 | Float newfloat = new Float(); |
164 | newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[0]).mValue; | 164 | newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[0]).mValue; |
165 | this._mThread.currentFrame.OpStack.Push(newfloat); | 165 | this._mThread.currentFrame.OpStack.Push(newfloat); |
166 | } | 166 | } |
167 | } | 167 | } |
168 | result = true; | 168 | result = true; |
169 | break; | 169 | break; |
170 | case 35: | 170 | case 35: |
171 | if (this._mThread.currentFrame.LocalVariables[1] != null) | 171 | if (this._mThread.currentFrame.LocalVariables[1] != null) |
172 | { | 172 | { |
173 | if (this._mThread.currentFrame.LocalVariables[1] is Float) | 173 | if (this._mThread.currentFrame.LocalVariables[1] is Float) |
174 | { | 174 | { |
175 | Float newfloat = new Float(); | 175 | Float newfloat = new Float(); |
176 | newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[1]).mValue; | 176 | newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[1]).mValue; |
177 | this._mThread.currentFrame.OpStack.Push(newfloat); | 177 | this._mThread.currentFrame.OpStack.Push(newfloat); |
178 | } | 178 | } |
179 | } | 179 | } |
180 | result = true; | 180 | result = true; |
181 | break; | 181 | break; |
182 | case 36: | 182 | case 36: |
183 | if (this._mThread.currentFrame.LocalVariables[2] != null) | 183 | if (this._mThread.currentFrame.LocalVariables[2] != null) |
184 | { | 184 | { |
185 | if (this._mThread.currentFrame.LocalVariables[2] is Float) | 185 | if (this._mThread.currentFrame.LocalVariables[2] is Float) |
186 | { | 186 | { |
187 | Float newfloat = new Float(); | 187 | Float newfloat = new Float(); |
188 | newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[2]).mValue; | 188 | newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[2]).mValue; |
189 | this._mThread.currentFrame.OpStack.Push(newfloat); | 189 | this._mThread.currentFrame.OpStack.Push(newfloat); |
190 | } | 190 | } |
191 | } | 191 | } |
192 | result = true; | 192 | result = true; |
193 | break; | 193 | break; |
194 | case 37: | 194 | case 37: |
195 | if (this._mThread.currentFrame.LocalVariables[3] != null) | 195 | if (this._mThread.currentFrame.LocalVariables[3] != null) |
196 | { | 196 | { |
197 | if (this._mThread.currentFrame.LocalVariables[3] is Float) | 197 | if (this._mThread.currentFrame.LocalVariables[3] is Float) |
198 | { | 198 | { |
199 | Float newfloat = new Float(); | 199 | Float newfloat = new Float(); |
200 | newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[3]).mValue; | 200 | newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[3]).mValue; |
201 | this._mThread.currentFrame.OpStack.Push(newfloat); | 201 | this._mThread.currentFrame.OpStack.Push(newfloat); |
202 | } | 202 | } |
203 | } | 203 | } |
204 | result = true; | 204 | result = true; |
205 | break; | 205 | break; |
206 | case 56: | 206 | case 56: |
207 | short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] )); | 207 | short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] )); |
208 | BaseType fstor = this._mThread.currentFrame.OpStack.Pop(); | 208 | BaseType fstor = this._mThread.currentFrame.OpStack.Pop(); |
209 | if (fstor is Float) | 209 | if (fstor is Float) |
210 | { | 210 | { |
211 | this._mThread.currentFrame.LocalVariables[findex] = (Float)fstor; | 211 | this._mThread.currentFrame.LocalVariables[findex] = (Float)fstor; |
212 | } | 212 | } |
213 | this._mThread.PC++; | 213 | this._mThread.PC++; |
214 | result = true; | 214 | result = true; |
215 | break; | 215 | break; |
216 | case 59: | 216 | case 59: |
217 | BaseType baset = this._mThread.currentFrame.OpStack.Pop(); | 217 | BaseType baset = this._mThread.currentFrame.OpStack.Pop(); |
218 | if (baset is Int) | 218 | if (baset is Int) |
219 | { | 219 | { |
220 | this._mThread.currentFrame.LocalVariables[0] = (Int)baset; | 220 | this._mThread.currentFrame.LocalVariables[0] = (Int)baset; |
221 | } | 221 | } |
222 | result = true; | 222 | result = true; |
223 | break; | 223 | break; |
224 | case 60: | 224 | case 60: |
225 | baset = this._mThread.currentFrame.OpStack.Pop(); | 225 | baset = this._mThread.currentFrame.OpStack.Pop(); |
226 | if (baset is Int) | 226 | if (baset is Int) |
227 | { | 227 | { |
228 | this._mThread.currentFrame.LocalVariables[1] = (Int)baset; | 228 | this._mThread.currentFrame.LocalVariables[1] = (Int)baset; |
229 | } | 229 | } |
230 | result = true; | 230 | result = true; |
231 | break; | 231 | break; |
232 | case 67: | 232 | case 67: |
233 | baset = this._mThread.currentFrame.OpStack.Pop(); | 233 | baset = this._mThread.currentFrame.OpStack.Pop(); |
234 | if (baset is Float) | 234 | if (baset is Float) |
235 | { | 235 | { |
236 | this._mThread.currentFrame.LocalVariables[0] = (Float)baset; | 236 | this._mThread.currentFrame.LocalVariables[0] = (Float)baset; |
237 | } | 237 | } |
238 | result = true; | 238 | result = true; |
239 | break; | 239 | break; |
240 | case 68: | 240 | case 68: |
241 | baset = this._mThread.currentFrame.OpStack.Pop(); | 241 | baset = this._mThread.currentFrame.OpStack.Pop(); |
242 | if (baset is Float) | 242 | if (baset is Float) |
243 | { | 243 | { |
244 | this._mThread.currentFrame.LocalVariables[1] = (Float)baset; | 244 | this._mThread.currentFrame.LocalVariables[1] = (Float)baset; |
245 | } | 245 | } |
246 | result = true; | 246 | result = true; |
247 | break; | 247 | break; |
248 | case 69: | 248 | case 69: |
249 | baset = this._mThread.currentFrame.OpStack.Pop(); | 249 | baset = this._mThread.currentFrame.OpStack.Pop(); |
250 | if (baset is Float) | 250 | if (baset is Float) |
251 | { | 251 | { |
252 | this._mThread.currentFrame.LocalVariables[2] = (Float)baset; | 252 | this._mThread.currentFrame.LocalVariables[2] = (Float)baset; |
253 | } | 253 | } |
254 | result = true; | 254 | result = true; |
255 | break; | 255 | break; |
256 | case 70: | 256 | case 70: |
257 | baset = this._mThread.currentFrame.OpStack.Pop(); | 257 | baset = this._mThread.currentFrame.OpStack.Pop(); |
258 | if (baset is Float) | 258 | if (baset is Float) |
259 | { | 259 | { |
260 | this._mThread.currentFrame.LocalVariables[3] = (Float)baset; | 260 | this._mThread.currentFrame.LocalVariables[3] = (Float)baset; |
261 | } | 261 | } |
262 | result = true; | 262 | result = true; |
263 | break; | 263 | break; |
264 | case 87: | 264 | case 87: |
265 | this._mThread.currentFrame.OpStack.Pop(); | 265 | this._mThread.currentFrame.OpStack.Pop(); |
266 | result = true; | 266 | result = true; |
267 | break; | 267 | break; |
268 | case 98: | 268 | case 98: |
269 | BaseType bf2 = this._mThread.currentFrame.OpStack.Pop(); | 269 | BaseType bf2 = this._mThread.currentFrame.OpStack.Pop(); |
270 | BaseType bf1 = this._mThread.currentFrame.OpStack.Pop(); | 270 | BaseType bf1 = this._mThread.currentFrame.OpStack.Pop(); |
271 | if (bf1 is Float && bf2 is Float) | 271 | if (bf1 is Float && bf2 is Float) |
272 | { | 272 | { |
273 | Float nflt = new Float(); | 273 | Float nflt = new Float(); |
274 | nflt.mValue = ((Float)bf1).mValue + ((Float)bf2).mValue; | 274 | nflt.mValue = ((Float)bf1).mValue + ((Float)bf2).mValue; |
275 | this._mThread.currentFrame.OpStack.Push(nflt); | 275 | this._mThread.currentFrame.OpStack.Push(nflt); |
276 | } | 276 | } |
277 | result = true; | 277 | result = true; |
278 | break; | 278 | break; |
279 | case 102: | 279 | case 102: |
280 | BaseType bsf2 = this._mThread.currentFrame.OpStack.Pop(); | 280 | BaseType bsf2 = this._mThread.currentFrame.OpStack.Pop(); |
281 | BaseType bsf1 = this._mThread.currentFrame.OpStack.Pop(); | 281 | BaseType bsf1 = this._mThread.currentFrame.OpStack.Pop(); |
282 | if (bsf1 is Float && bsf2 is Float) | 282 | if (bsf1 is Float && bsf2 is Float) |
283 | { | 283 | { |
284 | Float resf = new Float(); | 284 | Float resf = new Float(); |
285 | resf.mValue = ((Float)bsf1).mValue - ((Float)bsf2).mValue; | 285 | resf.mValue = ((Float)bsf1).mValue - ((Float)bsf2).mValue; |
286 | this._mThread.currentFrame.OpStack.Push(resf); | 286 | this._mThread.currentFrame.OpStack.Push(resf); |
287 | } | 287 | } |
288 | result = true; | 288 | result = true; |
289 | break; | 289 | break; |
290 | case 104: //check the order of the two values off the stack is correct | 290 | case 104: //check the order of the two values off the stack is correct |
291 | BaseType bs2 = this._mThread.currentFrame.OpStack.Pop(); | 291 | BaseType bs2 = this._mThread.currentFrame.OpStack.Pop(); |
292 | BaseType bs1 = this._mThread.currentFrame.OpStack.Pop(); | 292 | BaseType bs1 = this._mThread.currentFrame.OpStack.Pop(); |
293 | if (bs1 is Int && bs2 is Int) | 293 | if (bs1 is Int && bs2 is Int) |
294 | { | 294 | { |
295 | Int nInt = new Int(); | 295 | Int nInt = new Int(); |
296 | nInt.mValue = ((Int)bs1).mValue * ((Int)bs2).mValue; | 296 | nInt.mValue = ((Int)bs1).mValue * ((Int)bs2).mValue; |
297 | this._mThread.currentFrame.OpStack.Push(nInt); | 297 | this._mThread.currentFrame.OpStack.Push(nInt); |
298 | } | 298 | } |
299 | result = true; | 299 | result = true; |
300 | break; | 300 | break; |
301 | case 132: | 301 | case 132: |
302 | if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] != null) | 302 | if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] != null) |
303 | { | 303 | { |
304 | if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] is Int) | 304 | if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] is Int) |
305 | { | 305 | { |
306 | ((Int)this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]]).mValue += (sbyte) GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]; | 306 | ((Int)this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]]).mValue += (sbyte) GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]; |
307 | } | 307 | } |
308 | } | 308 | } |
309 | this._mThread.PC += 2; | 309 | this._mThread.PC += 2; |
310 | result = true; | 310 | result = true; |
311 | break; | 311 | break; |
312 | case 139: | 312 | case 139: |
313 | BaseType conv1 = this._mThread.currentFrame.OpStack.Pop(); | 313 | BaseType conv1 = this._mThread.currentFrame.OpStack.Pop(); |
314 | if (conv1 is Float) | 314 | if (conv1 is Float) |
315 | { | 315 | { |
316 | Int newconv = new Int(); | 316 | Int newconv = new Int(); |
317 | newconv.mValue = (int)((Float)conv1).mValue; | 317 | newconv.mValue = (int)((Float)conv1).mValue; |
318 | this._mThread.currentFrame.OpStack.Push(newconv); | 318 | this._mThread.currentFrame.OpStack.Push(newconv); |
319 | } | 319 | } |
320 | result = true; | 320 | result = true; |
321 | break; | 321 | break; |
322 | case 149: | 322 | case 149: |
323 | BaseType flcom2 = this._mThread.currentFrame.OpStack.Pop(); | 323 | BaseType flcom2 = this._mThread.currentFrame.OpStack.Pop(); |
324 | BaseType flcom1 = this._mThread.currentFrame.OpStack.Pop(); | 324 | BaseType flcom1 = this._mThread.currentFrame.OpStack.Pop(); |
325 | if (flcom1 is Float && flcom2 is Float) | 325 | if (flcom1 is Float && flcom2 is Float) |
326 | { | 326 | { |
327 | Int compres = new Int(); | 327 | Int compres = new Int(); |
328 | if (((Float)flcom1).mValue < ((Float)flcom2).mValue) | 328 | if (((Float)flcom1).mValue < ((Float)flcom2).mValue) |
329 | { | 329 | { |
330 | compres.mValue = -1; | 330 | compres.mValue = -1; |
331 | } | 331 | } |
332 | else if (((Float)flcom1).mValue > ((Float)flcom2).mValue) | 332 | else if (((Float)flcom1).mValue > ((Float)flcom2).mValue) |
333 | { | 333 | { |
334 | compres.mValue = 1; | 334 | compres.mValue = 1; |
335 | } | 335 | } |
336 | else | 336 | else |
337 | { | 337 | { |
338 | compres.mValue = 0; | 338 | compres.mValue = 0; |
339 | } | 339 | } |
340 | this._mThread.currentFrame.OpStack.Push(compres); | 340 | this._mThread.currentFrame.OpStack.Push(compres); |
341 | } | 341 | } |
342 | result = true; | 342 | result = true; |
343 | break; | 343 | break; |
344 | case 158: | 344 | case 158: |
345 | short compareoffset1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); | 345 | short compareoffset1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); |
346 | BaseType comp1 = this._mThread.currentFrame.OpStack.Pop(); | 346 | BaseType comp1 = this._mThread.currentFrame.OpStack.Pop(); |
347 | if (comp1 is Int) | 347 | if (comp1 is Int) |
348 | { | 348 | { |
349 | if (((Int)comp1).mValue <= 0) | 349 | if (((Int)comp1).mValue <= 0) |
350 | { | 350 | { |
351 | this._mThread.PC += -1 + compareoffset1; | 351 | this._mThread.PC += -1 + compareoffset1; |
352 | } | 352 | } |
353 | else | 353 | else |
354 | { | 354 | { |
355 | this._mThread.PC += 2; | 355 | this._mThread.PC += 2; |
356 | } | 356 | } |
357 | } | 357 | } |
358 | else | 358 | else |
359 | { | 359 | { |
360 | this._mThread.PC += 2; | 360 | this._mThread.PC += 2; |
361 | } | 361 | } |
362 | result = true; | 362 | result = true; |
363 | break; | 363 | break; |
364 | case 162: | 364 | case 162: |
365 | short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); | 365 | short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); |
366 | BaseType bc2 = this._mThread.currentFrame.OpStack.Pop(); | 366 | BaseType bc2 = this._mThread.currentFrame.OpStack.Pop(); |
367 | BaseType bc1 = this._mThread.currentFrame.OpStack.Pop(); | 367 | BaseType bc1 = this._mThread.currentFrame.OpStack.Pop(); |
368 | if (bc1 is Int && bc2 is Int) | 368 | if (bc1 is Int && bc2 is Int) |
369 | { | 369 | { |
370 | //Console.WriteLine("comparing " + ((Int)bc1).mValue + " and " + ((Int)bc2).mValue); | 370 | //Console.WriteLine("comparing " + ((Int)bc1).mValue + " and " + ((Int)bc2).mValue); |
371 | if (((Int)bc1).mValue >= ((Int)bc2).mValue) | 371 | if (((Int)bc1).mValue >= ((Int)bc2).mValue) |
372 | { | 372 | { |
373 | // Console.WriteLine("branch compare true , offset is " +compareoffset); | 373 | // Console.WriteLine("branch compare true , offset is " +compareoffset); |
374 | // Console.WriteLine("current PC is " + this._mThread.PC); | 374 | // Console.WriteLine("current PC is " + this._mThread.PC); |
375 | this._mThread.PC += -1 + compareoffset; | 375 | this._mThread.PC += -1 + compareoffset; |
376 | //Console.WriteLine("new PC is " + this._mThread.PC); | 376 | //Console.WriteLine("new PC is " + this._mThread.PC); |
377 | } | 377 | } |
378 | else | 378 | else |
379 | { | 379 | { |
380 | //Console.WriteLine("branch compare false"); | 380 | //Console.WriteLine("branch compare false"); |
381 | this._mThread.PC += 2; | 381 | this._mThread.PC += 2; |
382 | } | 382 | } |
383 | } | 383 | } |
384 | else | 384 | else |
385 | { | 385 | { |
386 | this._mThread.PC += 2; | 386 | this._mThread.PC += 2; |
387 | } | 387 | } |
388 | result = true; | 388 | result = true; |
389 | break; | 389 | break; |
390 | case 164: | 390 | case 164: |
391 | short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); | 391 | short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); |
392 | BaseType bcl2 = this._mThread.currentFrame.OpStack.Pop(); | 392 | BaseType bcl2 = this._mThread.currentFrame.OpStack.Pop(); |
393 | BaseType bcl1 = this._mThread.currentFrame.OpStack.Pop(); | 393 | BaseType bcl1 = this._mThread.currentFrame.OpStack.Pop(); |
394 | if (bcl1 is Int && bcl2 is Int) | 394 | if (bcl1 is Int && bcl2 is Int) |
395 | { | 395 | { |
396 | //Console.WriteLine("comparing " + ((Int)bcl1).mValue + " and " + ((Int)bcl2).mValue); | 396 | //Console.WriteLine("comparing " + ((Int)bcl1).mValue + " and " + ((Int)bcl2).mValue); |
397 | if (((Int)bcl1).mValue <= ((Int)bcl2).mValue) | 397 | if (((Int)bcl1).mValue <= ((Int)bcl2).mValue) |
398 | { | 398 | { |
399 | // Console.WriteLine("branch compare true , offset is " + compareloffset); | 399 | // Console.WriteLine("branch compare true , offset is " + compareloffset); |
400 | // Console.WriteLine("current PC is " + this._mThread.PC); | 400 | // Console.WriteLine("current PC is " + this._mThread.PC); |
401 | this._mThread.PC += -1 + compareloffset; | 401 | this._mThread.PC += -1 + compareloffset; |
402 | // Console.WriteLine("new PC is " + this._mThread.PC); | 402 | // Console.WriteLine("new PC is " + this._mThread.PC); |
403 | } | 403 | } |
404 | else | 404 | else |
405 | { | 405 | { |
406 | //Console.WriteLine("branch compare false"); | 406 | //Console.WriteLine("branch compare false"); |
407 | this._mThread.PC += 2; | 407 | this._mThread.PC += 2; |
408 | } | 408 | } |
409 | } | 409 | } |
410 | else | 410 | else |
411 | { | 411 | { |
412 | this._mThread.PC += 2; | 412 | this._mThread.PC += 2; |
413 | } | 413 | } |
414 | result = true; | 414 | result = true; |
415 | break; | 415 | break; |
416 | case 167: | 416 | case 167: |
417 | short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]); | 417 | short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]); |
418 | this._mThread.PC += -1 + offset; | 418 | this._mThread.PC += -1 + offset; |
419 | result = true; | 419 | result = true; |
420 | break; | 420 | break; |
421 | } | 421 | } |
422 | 422 | ||
423 | return result; | 423 | return result; |
424 | } | 424 | } |
425 | } | 425 | } |
426 | } | 426 | } |
427 | } | 427 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Methods.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Methods.cs index e2e2b7c..6b85fcc 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Methods.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Methods.cs | |||
@@ -1,96 +1,96 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | using OpenSim.Region.Scripting.EmbeddedJVM.Types; | 31 | using OpenSim.Region.Scripting.EmbeddedJVM.Types; |
32 | using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes; | 32 | using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes; |
33 | using OpenSim.Framework.Interfaces; | 33 | using OpenSim.Framework.Interfaces; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Types; | 35 | using OpenSim.Framework.Types; |
36 | 36 | ||
37 | namespace OpenSim.Region.Scripting.EmbeddedJVM | 37 | namespace OpenSim.Region.Scripting.EmbeddedJVM |
38 | { | 38 | { |
39 | partial class Thread | 39 | partial class Thread |
40 | { | 40 | { |
41 | private partial class Interpreter | 41 | private partial class Interpreter |
42 | { | 42 | { |
43 | private bool IsMethodOpCode(byte opcode) | 43 | private bool IsMethodOpCode(byte opcode) |
44 | { | 44 | { |
45 | bool result = false; | 45 | bool result = false; |
46 | switch (opcode) | 46 | switch (opcode) |
47 | { | 47 | { |
48 | case 184: | 48 | case 184: |
49 | short refIndex = (short) ((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]); | 49 | short refIndex = (short) ((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]); |
50 | if (this._mThread.currentClass._constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef) | 50 | if (this._mThread.currentClass._constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef) |
51 | { | 51 | { |
52 | string typ = ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Type.Value; | 52 | string typ = ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Type.Value; |
53 | string typeparam = ""; | 53 | string typeparam = ""; |
54 | string typereturn = ""; | 54 | string typereturn = ""; |
55 | int firstbrak = 0; | 55 | int firstbrak = 0; |
56 | int secondbrak = 0; | 56 | int secondbrak = 0; |
57 | firstbrak = typ.LastIndexOf('('); | 57 | firstbrak = typ.LastIndexOf('('); |
58 | secondbrak = typ.LastIndexOf(')'); | 58 | secondbrak = typ.LastIndexOf(')'); |
59 | typeparam = typ.Substring(firstbrak + 1, secondbrak - firstbrak - 1); | 59 | typeparam = typ.Substring(firstbrak + 1, secondbrak - firstbrak - 1); |
60 | typereturn = typ.Substring(secondbrak + 1, typ.Length - secondbrak - 1); | 60 | typereturn = typ.Substring(secondbrak + 1, typ.Length - secondbrak - 1); |
61 | if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == this._mThread.currentClass.mClass.Name.Value) | 61 | if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == this._mThread.currentClass.mClass.Name.Value) |
62 | { | 62 | { |
63 | //calling a method in this class | 63 | //calling a method in this class |
64 | if (typeparam.Length == 0) | 64 | if (typeparam.Length == 0) |
65 | { | 65 | { |
66 | this._mThread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, (this._mThread.PC + 2)); | 66 | this._mThread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, (this._mThread.PC + 2)); |
67 | } | 67 | } |
68 | else | 68 | else |
69 | { | 69 | { |
70 | this._mThread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this._mThread.PC + 2)); | 70 | this._mThread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this._mThread.PC + 2)); |
71 | } | 71 | } |
72 | } | 72 | } |
73 | else | 73 | else |
74 | { | 74 | { |
75 | //calling a method of a different class | 75 | //calling a method of a different class |
76 | 76 | ||
77 | // OpenSimAPI Class | 77 | // OpenSimAPI Class |
78 | if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI") | 78 | if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI") |
79 | { | 79 | { |
80 | this._mThread.scriptInfo.api.CallMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, null); | 80 | this._mThread.scriptInfo.api.CallMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, null); |
81 | } | 81 | } |
82 | } | 82 | } |
83 | } | 83 | } |
84 | else | 84 | else |
85 | { | 85 | { |
86 | this._mThread.PC += 2; | 86 | this._mThread.PC += 2; |
87 | } | 87 | } |
88 | result = true; | 88 | result = true; |
89 | break; | 89 | break; |
90 | } | 90 | } |
91 | 91 | ||
92 | return result; | 92 | return result; |
93 | } | 93 | } |
94 | } | 94 | } |
95 | } | 95 | } |
96 | } | 96 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Return.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Return.cs index 6444776..3c18a11 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Return.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.Return.cs | |||
@@ -1,40 +1,40 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | 31 | ||
32 | namespace OpenSim.Region.Scripting.EmbeddedJVM | 32 | namespace OpenSim.Region.Scripting.EmbeddedJVM |
33 | { | 33 | { |
34 | partial class Thread | 34 | partial class Thread |
35 | { | 35 | { |
36 | private partial class Interpreter | 36 | private partial class Interpreter |
37 | { | 37 | { |
38 | } | 38 | } |
39 | } | 39 | } |
40 | } | 40 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.cs index d44f315..9961cbd 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Interpreter.cs | |||
@@ -1,135 +1,135 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | using OpenSim.Region.Scripting.EmbeddedJVM.Types; | 31 | using OpenSim.Region.Scripting.EmbeddedJVM.Types; |
32 | using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes; | 32 | using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes; |
33 | 33 | ||
34 | namespace OpenSim.Region.Scripting.EmbeddedJVM | 34 | namespace OpenSim.Region.Scripting.EmbeddedJVM |
35 | { | 35 | { |
36 | partial class Thread | 36 | partial class Thread |
37 | { | 37 | { |
38 | private partial class Interpreter | 38 | private partial class Interpreter |
39 | { | 39 | { |
40 | private Thread _mThread; | 40 | private Thread _mThread; |
41 | 41 | ||
42 | public Interpreter(Thread parentThread) | 42 | public Interpreter(Thread parentThread) |
43 | { | 43 | { |
44 | _mThread = parentThread; | 44 | _mThread = parentThread; |
45 | } | 45 | } |
46 | 46 | ||
47 | public bool Excute() | 47 | public bool Excute() |
48 | { | 48 | { |
49 | bool run = true; | 49 | bool run = true; |
50 | byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC++]; | 50 | byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC++]; |
51 | // Console.WriteLine("opCode is: " + currentOpCode); | 51 | // Console.WriteLine("opCode is: " + currentOpCode); |
52 | bool handled = false; | 52 | bool handled = false; |
53 | 53 | ||
54 | handled = this.IsLogicOpCode(currentOpCode); | 54 | handled = this.IsLogicOpCode(currentOpCode); |
55 | if (!handled) | 55 | if (!handled) |
56 | { | 56 | { |
57 | handled = this.IsMethodOpCode(currentOpCode); | 57 | handled = this.IsMethodOpCode(currentOpCode); |
58 | } | 58 | } |
59 | if (!handled) | 59 | if (!handled) |
60 | { | 60 | { |
61 | if (currentOpCode == 172) | 61 | if (currentOpCode == 172) |
62 | { | 62 | { |
63 | if (this._mThread.stack.StackFrames.Count > 1) | 63 | if (this._mThread.stack.StackFrames.Count > 1) |
64 | { | 64 | { |
65 | Console.WriteLine("returning int from function"); | 65 | Console.WriteLine("returning int from function"); |
66 | int retPC1 = this._mThread.currentFrame.ReturnPC; | 66 | int retPC1 = this._mThread.currentFrame.ReturnPC; |
67 | BaseType bas1 = this._mThread.currentFrame.OpStack.Pop(); | 67 | BaseType bas1 = this._mThread.currentFrame.OpStack.Pop(); |
68 | this._mThread.stack.StackFrames.Pop(); | 68 | this._mThread.stack.StackFrames.Pop(); |
69 | this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek(); | 69 | this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek(); |
70 | this._mThread.PC = retPC1; | 70 | this._mThread.PC = retPC1; |
71 | if (bas1 is Int) | 71 | if (bas1 is Int) |
72 | { | 72 | { |
73 | this._mThread.currentFrame.OpStack.Push((Int)bas1); | 73 | this._mThread.currentFrame.OpStack.Push((Int)bas1); |
74 | } | 74 | } |
75 | } | 75 | } |
76 | else | 76 | else |
77 | { | 77 | { |
78 | // Console.WriteLine("No parent function so ending program"); | 78 | // Console.WriteLine("No parent function so ending program"); |
79 | this._mThread.stack.StackFrames.Pop(); | 79 | this._mThread.stack.StackFrames.Pop(); |
80 | run = false; | 80 | run = false; |
81 | } | 81 | } |
82 | handled = true; | 82 | handled = true; |
83 | } | 83 | } |
84 | if (currentOpCode == 174) | 84 | if (currentOpCode == 174) |
85 | { | 85 | { |
86 | if (this._mThread.stack.StackFrames.Count > 1) | 86 | if (this._mThread.stack.StackFrames.Count > 1) |
87 | { | 87 | { |
88 | Console.WriteLine("returning float from function"); | 88 | Console.WriteLine("returning float from function"); |
89 | int retPC1 = this._mThread.currentFrame.ReturnPC; | 89 | int retPC1 = this._mThread.currentFrame.ReturnPC; |
90 | BaseType bas1 = this._mThread.currentFrame.OpStack.Pop(); | 90 | BaseType bas1 = this._mThread.currentFrame.OpStack.Pop(); |
91 | this._mThread.stack.StackFrames.Pop(); | 91 | this._mThread.stack.StackFrames.Pop(); |
92 | this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek(); | 92 | this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek(); |
93 | this._mThread.PC = retPC1; | 93 | this._mThread.PC = retPC1; |
94 | if (bas1 is Float) | 94 | if (bas1 is Float) |
95 | { | 95 | { |
96 | this._mThread.currentFrame.OpStack.Push((Float)bas1); | 96 | this._mThread.currentFrame.OpStack.Push((Float)bas1); |
97 | } | 97 | } |
98 | } | 98 | } |
99 | else | 99 | else |
100 | { | 100 | { |
101 | // Console.WriteLine("No parent function so ending program"); | 101 | // Console.WriteLine("No parent function so ending program"); |
102 | this._mThread.stack.StackFrames.Pop(); | 102 | this._mThread.stack.StackFrames.Pop(); |
103 | run = false; | 103 | run = false; |
104 | } | 104 | } |
105 | handled = true; | 105 | handled = true; |
106 | } | 106 | } |
107 | if (currentOpCode == 177) | 107 | if (currentOpCode == 177) |
108 | { | 108 | { |
109 | if (this._mThread.stack.StackFrames.Count > 1) | 109 | if (this._mThread.stack.StackFrames.Count > 1) |
110 | { | 110 | { |
111 | Console.WriteLine("returning from function"); | 111 | Console.WriteLine("returning from function"); |
112 | int retPC = this._mThread.currentFrame.ReturnPC; | 112 | int retPC = this._mThread.currentFrame.ReturnPC; |
113 | this._mThread.stack.StackFrames.Pop(); | 113 | this._mThread.stack.StackFrames.Pop(); |
114 | this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek(); | 114 | this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek(); |
115 | this._mThread.PC = retPC; | 115 | this._mThread.PC = retPC; |
116 | } | 116 | } |
117 | else | 117 | else |
118 | { | 118 | { |
119 | // Console.WriteLine("No parent function so ending program"); | 119 | // Console.WriteLine("No parent function so ending program"); |
120 | this._mThread.stack.StackFrames.Pop(); | 120 | this._mThread.stack.StackFrames.Pop(); |
121 | run = false; | 121 | run = false; |
122 | } | 122 | } |
123 | handled = true; | 123 | handled = true; |
124 | } | 124 | } |
125 | } | 125 | } |
126 | if (!handled) | 126 | if (!handled) |
127 | { | 127 | { |
128 | Console.WriteLine("opcode " + currentOpCode + " not been handled "); | 128 | Console.WriteLine("opcode " + currentOpCode + " not been handled "); |
129 | } | 129 | } |
130 | return run; | 130 | return run; |
131 | 131 | ||
132 | } | 132 | } |
133 | } | 133 | } |
134 | } | 134 | } |
135 | } | 135 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/MainMemory.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/MainMemory.cs index addb6ff..7174975 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/MainMemory.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/MainMemory.cs | |||
@@ -1,45 +1,45 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | 31 | ||
32 | namespace OpenSim.Region.Scripting.EmbeddedJVM | 32 | namespace OpenSim.Region.Scripting.EmbeddedJVM |
33 | { | 33 | { |
34 | public class MainMemory | 34 | public class MainMemory |
35 | { | 35 | { |
36 | public Heap HeapArea; | 36 | public Heap HeapArea; |
37 | public MethodMemory MethodArea; | 37 | public MethodMemory MethodArea; |
38 | 38 | ||
39 | public MainMemory() | 39 | public MainMemory() |
40 | { | 40 | { |
41 | MethodArea = new MethodMemory(); | 41 | MethodArea = new MethodMemory(); |
42 | HeapArea = new Heap(); | 42 | HeapArea = new Heap(); |
43 | } | 43 | } |
44 | } | 44 | } |
45 | } | 45 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/MethodMemory.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/MethodMemory.cs index 7d69e91..5f29091 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/MethodMemory.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/MethodMemory.cs | |||
@@ -1,46 +1,46 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | 31 | ||
32 | namespace OpenSim.Region.Scripting.EmbeddedJVM | 32 | namespace OpenSim.Region.Scripting.EmbeddedJVM |
33 | { | 33 | { |
34 | public class MethodMemory | 34 | public class MethodMemory |
35 | { | 35 | { |
36 | public byte[] MethodBuffer; | 36 | public byte[] MethodBuffer; |
37 | public List<ClassRecord> Classes = new List<ClassRecord>(); | 37 | public List<ClassRecord> Classes = new List<ClassRecord>(); |
38 | public int NextMethodPC = 0; | 38 | public int NextMethodPC = 0; |
39 | public int Methodcount = 0; | 39 | public int Methodcount = 0; |
40 | 40 | ||
41 | public MethodMemory() | 41 | public MethodMemory() |
42 | { | 42 | { |
43 | MethodBuffer = new byte[20000]; | 43 | MethodBuffer = new byte[20000]; |
44 | } | 44 | } |
45 | } | 45 | } |
46 | } | 46 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Object.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Object.cs index 6a0a1a4..8acb2bd 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Object.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Object.cs | |||
@@ -1,37 +1,37 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | 31 | ||
32 | namespace OpenSim.Region.Scripting.EmbeddedJVM | 32 | namespace OpenSim.Region.Scripting.EmbeddedJVM |
33 | { | 33 | { |
34 | public class Object | 34 | public class Object |
35 | { | 35 | { |
36 | } | 36 | } |
37 | } | 37 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Stack.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Stack.cs index 74f0a7f..7c12678 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Stack.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Stack.cs | |||
@@ -1,42 +1,42 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | 31 | ||
32 | namespace OpenSim.Region.Scripting.EmbeddedJVM | 32 | namespace OpenSim.Region.Scripting.EmbeddedJVM |
33 | { | 33 | { |
34 | public class Stack | 34 | public class Stack |
35 | { | 35 | { |
36 | public Stack<StackFrame> StackFrames = new Stack<StackFrame>(); | 36 | public Stack<StackFrame> StackFrames = new Stack<StackFrame>(); |
37 | 37 | ||
38 | public Stack() | 38 | public Stack() |
39 | { | 39 | { |
40 | } | 40 | } |
41 | } | 41 | } |
42 | } | 42 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/StackFrame.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/StackFrame.cs index 1072395..76257b8 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/StackFrame.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/StackFrame.cs | |||
@@ -1,49 +1,49 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | using OpenSim.Region.Scripting.EmbeddedJVM.Types; | 31 | using OpenSim.Region.Scripting.EmbeddedJVM.Types; |
32 | 32 | ||
33 | namespace OpenSim.Region.Scripting.EmbeddedJVM | 33 | namespace OpenSim.Region.Scripting.EmbeddedJVM |
34 | { | 34 | { |
35 | public class StackFrame | 35 | public class StackFrame |
36 | { | 36 | { |
37 | public BaseType[] LocalVariables; | 37 | public BaseType[] LocalVariables; |
38 | public Stack<BaseType> OpStack = new Stack<BaseType>(); | 38 | public Stack<BaseType> OpStack = new Stack<BaseType>(); |
39 | 39 | ||
40 | public int ReturnPC = 0; | 40 | public int ReturnPC = 0; |
41 | public ClassRecord CallingClass = null; | 41 | public ClassRecord CallingClass = null; |
42 | 42 | ||
43 | public StackFrame() | 43 | public StackFrame() |
44 | { | 44 | { |
45 | LocalVariables = new BaseType[20]; | 45 | LocalVariables = new BaseType[20]; |
46 | } | 46 | } |
47 | 47 | ||
48 | } | 48 | } |
49 | } | 49 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Thread.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Thread.cs index 59f3042..eda2640 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Thread.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JVM/Thread.cs | |||
@@ -1,119 +1,119 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | using OpenSim.Region.Scripting.EmbeddedJVM.Types; | 31 | using OpenSim.Region.Scripting.EmbeddedJVM.Types; |
32 | using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes; | 32 | using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Interfaces; | 34 | using OpenSim.Framework.Interfaces; |
35 | using OpenSim.Region.Environment.Scenes; | 35 | using OpenSim.Region.Environment.Scenes; |
36 | using OpenSim.Region.Scripting; | 36 | using OpenSim.Region.Scripting; |
37 | 37 | ||
38 | namespace OpenSim.Region.Scripting.EmbeddedJVM | 38 | namespace OpenSim.Region.Scripting.EmbeddedJVM |
39 | { | 39 | { |
40 | public partial class Thread | 40 | public partial class Thread |
41 | { | 41 | { |
42 | // Is this smart? | 42 | // Is this smart? |
43 | public static MainMemory GlobalMemory; | 43 | public static MainMemory GlobalMemory; |
44 | public static Scene World; | 44 | public static Scene World; |
45 | private int PC = 0; | 45 | private int PC = 0; |
46 | private Stack stack; | 46 | private Stack stack; |
47 | private Interpreter mInterpreter; | 47 | private Interpreter mInterpreter; |
48 | public ClassRecord currentClass; | 48 | public ClassRecord currentClass; |
49 | public ClassInstance currentInstance; | 49 | public ClassInstance currentInstance; |
50 | private StackFrame currentFrame; | 50 | private StackFrame currentFrame; |
51 | public int excutionCounter = 0; | 51 | public int excutionCounter = 0; |
52 | public bool running = false; | 52 | public bool running = false; |
53 | 53 | ||
54 | public ScriptInfo scriptInfo; | 54 | public ScriptInfo scriptInfo; |
55 | 55 | ||
56 | public Thread() | 56 | public Thread() |
57 | { | 57 | { |
58 | this.mInterpreter = new Interpreter(this); | 58 | this.mInterpreter = new Interpreter(this); |
59 | this.stack = new Stack(); | 59 | this.stack = new Stack(); |
60 | } | 60 | } |
61 | 61 | ||
62 | public void SetPC(int methodpointer) | 62 | public void SetPC(int methodpointer) |
63 | { | 63 | { |
64 | //Console.WriteLine("Thread PC has been set to " + methodpointer); | 64 | //Console.WriteLine("Thread PC has been set to " + methodpointer); |
65 | PC = methodpointer; | 65 | PC = methodpointer; |
66 | } | 66 | } |
67 | 67 | ||
68 | public void StartMethod(ClassRecord rec, string methName) | 68 | public void StartMethod(ClassRecord rec, string methName) |
69 | { | 69 | { |
70 | currentFrame = new StackFrame(); | 70 | currentFrame = new StackFrame(); |
71 | this.stack.StackFrames.Push(currentFrame); | 71 | this.stack.StackFrames.Push(currentFrame); |
72 | this.currentClass = rec; | 72 | this.currentClass = rec; |
73 | currentClass.StartMethod(this, methName); | 73 | currentClass.StartMethod(this, methName); |
74 | } | 74 | } |
75 | 75 | ||
76 | public void StartMethod( string methName) | 76 | public void StartMethod( string methName) |
77 | { | 77 | { |
78 | currentFrame = new StackFrame(); | 78 | currentFrame = new StackFrame(); |
79 | this.stack.StackFrames.Push(currentFrame); | 79 | this.stack.StackFrames.Push(currentFrame); |
80 | currentClass.StartMethod(this, methName); | 80 | currentClass.StartMethod(this, methName); |
81 | } | 81 | } |
82 | 82 | ||
83 | public void JumpToStaticVoidMethod(string methName, int returnPC) | 83 | public void JumpToStaticVoidMethod(string methName, int returnPC) |
84 | { | 84 | { |
85 | currentFrame = new StackFrame(); | 85 | currentFrame = new StackFrame(); |
86 | currentFrame.ReturnPC = returnPC; | 86 | currentFrame.ReturnPC = returnPC; |
87 | this.stack.StackFrames.Push(currentFrame); | 87 | this.stack.StackFrames.Push(currentFrame); |
88 | currentClass.StartMethod(this, methName); | 88 | currentClass.StartMethod(this, methName); |
89 | } | 89 | } |
90 | 90 | ||
91 | public void JumpToStaticParamMethod(string methName, string param, int returnPC) | 91 | public void JumpToStaticParamMethod(string methName, string param, int returnPC) |
92 | { | 92 | { |
93 | if (param == "I") | 93 | if (param == "I") |
94 | { | 94 | { |
95 | BaseType bs1 = currentFrame.OpStack.Pop(); | 95 | BaseType bs1 = currentFrame.OpStack.Pop(); |
96 | currentFrame = new StackFrame(); | 96 | currentFrame = new StackFrame(); |
97 | currentFrame.ReturnPC = returnPC; | 97 | currentFrame.ReturnPC = returnPC; |
98 | this.stack.StackFrames.Push(currentFrame); | 98 | this.stack.StackFrames.Push(currentFrame); |
99 | currentFrame.LocalVariables[0] = ((Int)bs1); | 99 | currentFrame.LocalVariables[0] = ((Int)bs1); |
100 | currentClass.StartMethod(this, methName); | 100 | currentClass.StartMethod(this, methName); |
101 | } | 101 | } |
102 | if (param == "F") | 102 | if (param == "F") |
103 | { | 103 | { |
104 | 104 | ||
105 | } | 105 | } |
106 | } | 106 | } |
107 | 107 | ||
108 | public void JumpToClassStaticVoidMethod(string className, string methName, int returnPC) | 108 | public void JumpToClassStaticVoidMethod(string className, string methName, int returnPC) |
109 | { | 109 | { |
110 | 110 | ||
111 | } | 111 | } |
112 | 112 | ||
113 | public bool Excute() | 113 | public bool Excute() |
114 | { | 114 | { |
115 | excutionCounter++; | 115 | excutionCounter++; |
116 | return this.mInterpreter.Excute(); | 116 | return this.mInterpreter.Excute(); |
117 | } | 117 | } |
118 | } | 118 | } |
119 | } | 119 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JavaEngine.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JavaEngine.cs index a884e2b..58cdf49 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JavaEngine.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/JavaEngine.cs | |||
@@ -1,29 +1,29 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | 4 | ||
5 | using OpenSim.Region.Scripting; | 5 | using OpenSim.Region.Scripting; |
6 | using OpenSim.Region.Scripting.EmbeddedJVM; | 6 | using OpenSim.Region.Scripting.EmbeddedJVM; |
7 | 7 | ||
8 | namespace OpenSim.Region.Scripting | 8 | namespace OpenSim.Region.Scripting |
9 | { | 9 | { |
10 | public class JavaEngine : IScriptCompiler | 10 | public class JavaEngine : IScriptCompiler |
11 | { | 11 | { |
12 | public string FileExt() | 12 | public string FileExt() |
13 | { | 13 | { |
14 | return ".java"; | 14 | return ".java"; |
15 | } | 15 | } |
16 | 16 | ||
17 | public Dictionary<string, IScript> compile(string filename) | 17 | public Dictionary<string, IScript> compile(string filename) |
18 | { | 18 | { |
19 | JVMScript script = new JVMScript(); | 19 | JVMScript script = new JVMScript(); |
20 | Dictionary<string, IScript> returns = new Dictionary<string, IScript>(); | 20 | Dictionary<string, IScript> returns = new Dictionary<string, IScript>(); |
21 | 21 | ||
22 | script.LoadScript(filename); | 22 | script.LoadScript(filename); |
23 | 23 | ||
24 | returns.Add(filename, script); | 24 | returns.Add(filename, script); |
25 | 25 | ||
26 | return returns; | 26 | return returns; |
27 | } | 27 | } |
28 | } | 28 | } |
29 | } | 29 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/OpenSimJVM.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/OpenSimJVM.cs index 8b38951..78c6f67 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/OpenSimJVM.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/OpenSimJVM.cs | |||
@@ -1,170 +1,170 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | using System.IO; | 31 | using System.IO; |
32 | using System.Threading; | 32 | using System.Threading; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Interfaces; | 34 | using OpenSim.Framework.Interfaces; |
35 | using OpenSim.Framework.Utilities; | 35 | using OpenSim.Framework.Utilities; |
36 | using OpenSim.Region.Scripting; | 36 | using OpenSim.Region.Scripting; |
37 | using OpenSim.Region.Environment.Scenes; | 37 | using OpenSim.Region.Environment.Scenes; |
38 | 38 | ||
39 | namespace OpenSim.Region.Scripting.EmbeddedJVM | 39 | namespace OpenSim.Region.Scripting.EmbeddedJVM |
40 | { | 40 | { |
41 | public class JVMScript : IScript | 41 | public class JVMScript : IScript |
42 | { | 42 | { |
43 | private List<Thread> _threads = new List<Thread>(); | 43 | private List<Thread> _threads = new List<Thread>(); |
44 | private BlockingQueue<CompileInfo> CompileScripts = new BlockingQueue<CompileInfo>(); | 44 | private BlockingQueue<CompileInfo> CompileScripts = new BlockingQueue<CompileInfo>(); |
45 | private MainMemory _mainMemory; | 45 | private MainMemory _mainMemory; |
46 | 46 | ||
47 | ScriptInfo scriptInfo; | 47 | ScriptInfo scriptInfo; |
48 | 48 | ||
49 | public void Initialise(ScriptInfo info) | 49 | public void Initialise(ScriptInfo info) |
50 | { | 50 | { |
51 | scriptInfo = info; | 51 | scriptInfo = info; |
52 | 52 | ||
53 | _mainMemory = new MainMemory(); | 53 | _mainMemory = new MainMemory(); |
54 | Thread.GlobalMemory = this._mainMemory; | 54 | Thread.GlobalMemory = this._mainMemory; |
55 | Thread.World = info.world; | 55 | Thread.World = info.world; |
56 | CompileScript(); | 56 | CompileScript(); |
57 | 57 | ||
58 | scriptInfo.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame); | 58 | scriptInfo.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame); |
59 | scriptInfo.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence); | 59 | scriptInfo.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence); |
60 | } | 60 | } |
61 | 61 | ||
62 | void events_OnNewPresence(ScenePresence presence) | 62 | void events_OnNewPresence(ScenePresence presence) |
63 | { | 63 | { |
64 | for (int i = 0; i < this._threads.Count; i++) | 64 | for (int i = 0; i < this._threads.Count; i++) |
65 | { | 65 | { |
66 | if (!this._threads[i].running) | 66 | if (!this._threads[i].running) |
67 | { | 67 | { |
68 | this._threads[i].StartMethod("OnNewPresence"); | 68 | this._threads[i].StartMethod("OnNewPresence"); |
69 | bool run = true; | 69 | bool run = true; |
70 | while (run) | 70 | while (run) |
71 | { | 71 | { |
72 | run = this._threads[i].Excute(); | 72 | run = this._threads[i].Excute(); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | void events_OnFrame() | 78 | void events_OnFrame() |
79 | { | 79 | { |
80 | for (int i = 0; i < this._threads.Count; i++) | 80 | for (int i = 0; i < this._threads.Count; i++) |
81 | { | 81 | { |
82 | if (!this._threads[i].running) | 82 | if (!this._threads[i].running) |
83 | { | 83 | { |
84 | this._threads[i].StartMethod("OnFrame"); | 84 | this._threads[i].StartMethod("OnFrame"); |
85 | bool run = true; | 85 | bool run = true; |
86 | while (run) | 86 | while (run) |
87 | { | 87 | { |
88 | run = this._threads[i].Excute(); | 88 | run = this._threads[i].Excute(); |
89 | } | 89 | } |
90 | } | 90 | } |
91 | } | 91 | } |
92 | } | 92 | } |
93 | 93 | ||
94 | public string getName() | 94 | public string getName() |
95 | { | 95 | { |
96 | return "JVM Scripting Engine"; | 96 | return "JVM Scripting Engine"; |
97 | } | 97 | } |
98 | 98 | ||
99 | public void LoadScript(string script) | 99 | public void LoadScript(string script) |
100 | { | 100 | { |
101 | Console.WriteLine("OpenSimJVM - loading new script: " + script); | 101 | Console.WriteLine("OpenSimJVM - loading new script: " + script); |
102 | CompileInfo comp = new CompileInfo(); | 102 | CompileInfo comp = new CompileInfo(); |
103 | comp.script = script; | 103 | comp.script = script; |
104 | comp.scriptName = script; | 104 | comp.scriptName = script; |
105 | this.CompileScripts.Enqueue(comp); | 105 | this.CompileScripts.Enqueue(comp); |
106 | } | 106 | } |
107 | 107 | ||
108 | public void CompileScript() | 108 | public void CompileScript() |
109 | { | 109 | { |
110 | CompileInfo comp = this.CompileScripts.Dequeue(); | 110 | CompileInfo comp = this.CompileScripts.Dequeue(); |
111 | string script = comp.script; | 111 | string script = comp.script; |
112 | string scriptName = comp.scriptName; | 112 | string scriptName = comp.scriptName; |
113 | try | 113 | try |
114 | { | 114 | { |
115 | //need to compile the script into a java class file | 115 | //need to compile the script into a java class file |
116 | 116 | ||
117 | //first save it to a java source file | 117 | //first save it to a java source file |
118 | TextWriter tw = new StreamWriter(scriptName + ".java"); | 118 | TextWriter tw = new StreamWriter(scriptName + ".java"); |
119 | tw.WriteLine(script); | 119 | tw.WriteLine(script); |
120 | tw.Close(); | 120 | tw.Close(); |
121 | 121 | ||
122 | //now compile | 122 | //now compile |
123 | System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("javac.exe", "*.java"); | 123 | System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("javac.exe", "*.java"); |
124 | // psi.RedirectStandardOutput = true; | 124 | // psi.RedirectStandardOutput = true; |
125 | psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; | 125 | psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; |
126 | psi.UseShellExecute = false; | 126 | psi.UseShellExecute = false; |
127 | 127 | ||
128 | System.Diagnostics.Process javacomp; | 128 | System.Diagnostics.Process javacomp; |
129 | javacomp = System.Diagnostics.Process.Start(psi); | 129 | javacomp = System.Diagnostics.Process.Start(psi); |
130 | javacomp.WaitForExit(); | 130 | javacomp.WaitForExit(); |
131 | 131 | ||
132 | 132 | ||
133 | //now load in class file | 133 | //now load in class file |
134 | ClassRecord class1 = new ClassRecord(); | 134 | ClassRecord class1 = new ClassRecord(); |
135 | class1.LoadClassFromFile(scriptName + ".class"); | 135 | class1.LoadClassFromFile(scriptName + ".class"); |
136 | class1.PrintToConsole(); | 136 | class1.PrintToConsole(); |
137 | //Console.WriteLine(); | 137 | //Console.WriteLine(); |
138 | this._mainMemory.MethodArea.Classes.Add(class1); | 138 | this._mainMemory.MethodArea.Classes.Add(class1); |
139 | class1.AddMethodsToMemory(this._mainMemory.MethodArea); | 139 | class1.AddMethodsToMemory(this._mainMemory.MethodArea); |
140 | 140 | ||
141 | Thread newThread = new Thread(); | 141 | Thread newThread = new Thread(); |
142 | this._threads.Add(newThread); | 142 | this._threads.Add(newThread); |
143 | newThread.currentClass = class1; | 143 | newThread.currentClass = class1; |
144 | newThread.scriptInfo = scriptInfo; | 144 | newThread.scriptInfo = scriptInfo; |
145 | 145 | ||
146 | //now delete the created files | 146 | //now delete the created files |
147 | System.IO.File.Delete(scriptName + ".java"); | 147 | System.IO.File.Delete(scriptName + ".java"); |
148 | System.IO.File.Delete(scriptName + ".class"); | 148 | System.IO.File.Delete(scriptName + ".class"); |
149 | //this.OnFrame(); | 149 | //this.OnFrame(); |
150 | } | 150 | } |
151 | catch (Exception e) | 151 | catch (Exception e) |
152 | { | 152 | { |
153 | Console.WriteLine("exception"); | 153 | Console.WriteLine("exception"); |
154 | Console.WriteLine(e.StackTrace); | 154 | Console.WriteLine(e.StackTrace); |
155 | Console.WriteLine(e.Message); | 155 | Console.WriteLine(e.Message); |
156 | } | 156 | } |
157 | } | 157 | } |
158 | 158 | ||
159 | private class CompileInfo | 159 | private class CompileInfo |
160 | { | 160 | { |
161 | public string script; | 161 | public string script; |
162 | public string scriptName; | 162 | public string scriptName; |
163 | 163 | ||
164 | public CompileInfo() | 164 | public CompileInfo() |
165 | { | 165 | { |
166 | 166 | ||
167 | } | 167 | } |
168 | } | 168 | } |
169 | } | 169 | } |
170 | } | 170 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ArrayReference.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ArrayReference.cs index 40e2e22..0c4d623 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ArrayReference.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ArrayReference.cs | |||
@@ -1,10 +1,10 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | 4 | ||
5 | namespace OpenSim.Region.Scripting.EmbeddedJVM.Types | 5 | namespace OpenSim.Region.Scripting.EmbeddedJVM.Types |
6 | { | 6 | { |
7 | public class ArrayReference :BaseType | 7 | public class ArrayReference :BaseType |
8 | { | 8 | { |
9 | } | 9 | } |
10 | } | 10 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/BaseType.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/BaseType.cs index 4ee1720..7fc0a4f 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/BaseType.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/BaseType.cs | |||
@@ -1,10 +1,10 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | 4 | ||
5 | namespace OpenSim.Region.Scripting.EmbeddedJVM.Types | 5 | namespace OpenSim.Region.Scripting.EmbeddedJVM.Types |
6 | { | 6 | { |
7 | public class BaseType : Object | 7 | public class BaseType : Object |
8 | { | 8 | { |
9 | } | 9 | } |
10 | } | 10 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ObjectReference.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ObjectReference.cs index 75d8e41..7718765 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ObjectReference.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ObjectReference.cs | |||
@@ -1,16 +1,16 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | 4 | ||
5 | namespace OpenSim.Region.Scripting.EmbeddedJVM.Types | 5 | namespace OpenSim.Region.Scripting.EmbeddedJVM.Types |
6 | { | 6 | { |
7 | public class ObjectReference : BaseType | 7 | public class ObjectReference : BaseType |
8 | { | 8 | { |
9 | public ushort Reference; | 9 | public ushort Reference; |
10 | 10 | ||
11 | public ObjectReference() | 11 | public ObjectReference() |
12 | { | 12 | { |
13 | 13 | ||
14 | } | 14 | } |
15 | } | 15 | } |
16 | } | 16 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs index f5446dc..5a7b780 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs | |||
@@ -1,10 +1,10 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | 4 | ||
5 | namespace OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes | 5 | namespace OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes |
6 | { | 6 | { |
7 | public class Byte : BaseType | 7 | public class Byte : BaseType |
8 | { | 8 | { |
9 | } | 9 | } |
10 | } | 10 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs index 89824b4..c87ee8f 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs | |||
@@ -1,10 +1,10 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | 4 | ||
5 | namespace OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes | 5 | namespace OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes |
6 | { | 6 | { |
7 | public class Char : BaseType | 7 | public class Char : BaseType |
8 | { | 8 | { |
9 | } | 9 | } |
10 | } | 10 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs index 2638c20..982e748 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs | |||
@@ -1,16 +1,16 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | 4 | ||
5 | namespace OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes | 5 | namespace OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes |
6 | { | 6 | { |
7 | public class Float : BaseType | 7 | public class Float : BaseType |
8 | { | 8 | { |
9 | public float mValue = 0; | 9 | public float mValue = 0; |
10 | 10 | ||
11 | public Float() | 11 | public Float() |
12 | { | 12 | { |
13 | 13 | ||
14 | } | 14 | } |
15 | } | 15 | } |
16 | } | 16 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs index 0155e72..073a9b3 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs | |||
@@ -1,16 +1,16 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | 4 | ||
5 | namespace OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes | 5 | namespace OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes |
6 | { | 6 | { |
7 | public class Int : BaseType | 7 | public class Int : BaseType |
8 | { | 8 | { |
9 | public int mValue = 0; | 9 | public int mValue = 0; |
10 | 10 | ||
11 | public Int() | 11 | public Int() |
12 | { | 12 | { |
13 | 13 | ||
14 | } | 14 | } |
15 | } | 15 | } |
16 | } | 16 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/Engine.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/Engine.cs index 8b957d3..012a00e 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/Engine.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/Engine.cs | |||
@@ -1,140 +1,140 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Reflection; | 2 | using System.Reflection; |
3 | using System.Reflection.Emit; | 3 | using System.Reflection.Emit; |
4 | using System.Threading; | 4 | using System.Threading; |
5 | 5 | ||
6 | using OpenSim.Region.Scripting; | 6 | using OpenSim.Region.Scripting; |
7 | 7 | ||
8 | namespace OpenSim.ScriptEngines.LSL | 8 | namespace OpenSim.ScriptEngines.LSL |
9 | { | 9 | { |
10 | 10 | ||
11 | 11 | ||
12 | public class Engine | 12 | public class Engine |
13 | { | 13 | { |
14 | public void Start(ScriptInfo WorldAPI) | 14 | public void Start(ScriptInfo WorldAPI) |
15 | { | 15 | { |
16 | 16 | ||
17 | 17 | ||
18 | 18 | ||
19 | // Create Assembly Name | 19 | // Create Assembly Name |
20 | AssemblyName asmName = new AssemblyName(); | 20 | AssemblyName asmName = new AssemblyName(); |
21 | asmName.Name = "TestAssembly"; | 21 | asmName.Name = "TestAssembly"; |
22 | 22 | ||
23 | // Create Assembly | 23 | // Create Assembly |
24 | AssemblyBuilder asmBuilder = | 24 | AssemblyBuilder asmBuilder = |
25 | Thread.GetDomain().DefineDynamicAssembly | 25 | Thread.GetDomain().DefineDynamicAssembly |
26 | (asmName, AssemblyBuilderAccess.RunAndSave); | 26 | (asmName, AssemblyBuilderAccess.RunAndSave); |
27 | 27 | ||
28 | // Create a module (and save to disk) | 28 | // Create a module (and save to disk) |
29 | ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule | 29 | ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule |
30 | (asmName.Name, asmName.Name + ".dll"); | 30 | (asmName.Name, asmName.Name + ".dll"); |
31 | 31 | ||
32 | // Create a Class (/Type) | 32 | // Create a Class (/Type) |
33 | TypeBuilder typeBuilder = modBuilder.DefineType( | 33 | TypeBuilder typeBuilder = modBuilder.DefineType( |
34 | "MyClass", | 34 | "MyClass", |
35 | TypeAttributes.Public, | 35 | TypeAttributes.Public, |
36 | typeof(object), | 36 | typeof(object), |
37 | new Type[] { typeof(LSL_CLRInterface.LSLScript) }); | 37 | new Type[] { typeof(LSL_CLRInterface.LSLScript) }); |
38 | 38 | ||
39 | 39 | ||
40 | 40 | ||
41 | /* | 41 | /* |
42 | * Generate the IL itself | 42 | * Generate the IL itself |
43 | */ | 43 | */ |
44 | 44 | ||
45 | GenerateIL(WorldAPI, typeBuilder); | 45 | GenerateIL(WorldAPI, typeBuilder); |
46 | 46 | ||
47 | 47 | ||
48 | /* | 48 | /* |
49 | * Done generating, create a type and run it. | 49 | * Done generating, create a type and run it. |
50 | */ | 50 | */ |
51 | 51 | ||
52 | // Create type object for the class (after defining fields and methods) | 52 | // Create type object for the class (after defining fields and methods) |
53 | Type type = typeBuilder.CreateType(); | 53 | Type type = typeBuilder.CreateType(); |
54 | 54 | ||
55 | asmBuilder.Save("TestAssembly.dll"); | 55 | asmBuilder.Save("TestAssembly.dll"); |
56 | 56 | ||
57 | // Create an instance we can play with | 57 | // Create an instance we can play with |
58 | //LSLScript hello = (LSLScript)Activator.CreateInstance(type); | 58 | //LSLScript hello = (LSLScript)Activator.CreateInstance(type); |
59 | LSL_CLRInterface.LSLScript MyScript = (LSL_CLRInterface.LSLScript)Activator.CreateInstance(type); | 59 | LSL_CLRInterface.LSLScript MyScript = (LSL_CLRInterface.LSLScript)Activator.CreateInstance(type); |
60 | 60 | ||
61 | // Play with it | 61 | // Play with it |
62 | MyScript.event_state_entry("Test"); | 62 | MyScript.event_state_entry("Test"); |
63 | } | 63 | } |
64 | 64 | ||
65 | private void GenerateIL(ScriptInfo WorldAPI, TypeBuilder typeBuilder) | 65 | private void GenerateIL(ScriptInfo WorldAPI, TypeBuilder typeBuilder) |
66 | { | 66 | { |
67 | 67 | ||
68 | 68 | ||
69 | // For debug | 69 | // For debug |
70 | LSO_Parser LSOP = new LSO_Parser(); | 70 | LSO_Parser LSOP = new LSO_Parser(); |
71 | LSOP.ParseFile("LSO\\CloseToDefault.lso", WorldAPI, ref typeBuilder); | 71 | LSOP.ParseFile("LSO\\CloseToDefault.lso", WorldAPI, ref typeBuilder); |
72 | return; | 72 | return; |
73 | 73 | ||
74 | 74 | ||
75 | // Override a Method / Function | 75 | // Override a Method / Function |
76 | MethodBuilder methodBuilder = typeBuilder.DefineMethod("event_state_entry", | 76 | MethodBuilder methodBuilder = typeBuilder.DefineMethod("event_state_entry", |
77 | MethodAttributes.Private | MethodAttributes.Virtual, | 77 | MethodAttributes.Private | MethodAttributes.Virtual, |
78 | typeof(void), | 78 | typeof(void), |
79 | new Type[] { typeof(object) }); | 79 | new Type[] { typeof(object) }); |
80 | 80 | ||
81 | typeBuilder.DefineMethodOverride(methodBuilder, | 81 | typeBuilder.DefineMethodOverride(methodBuilder, |
82 | typeof(LSL_CLRInterface.LSLScript).GetMethod("event_state_entry")); | 82 | typeof(LSL_CLRInterface.LSLScript).GetMethod("event_state_entry")); |
83 | 83 | ||
84 | // Create the IL generator | 84 | // Create the IL generator |
85 | ILGenerator il = methodBuilder.GetILGenerator(); | 85 | ILGenerator il = methodBuilder.GetILGenerator(); |
86 | 86 | ||
87 | 87 | ||
88 | /* | 88 | /* |
89 | * TRY | 89 | * TRY |
90 | */ | 90 | */ |
91 | il.BeginExceptionBlock(); | 91 | il.BeginExceptionBlock(); |
92 | 92 | ||
93 | // Push "Hello World!" string to stack | 93 | // Push "Hello World!" string to stack |
94 | il.Emit(OpCodes.Ldstr, "Hello World!"); | 94 | il.Emit(OpCodes.Ldstr, "Hello World!"); |
95 | 95 | ||
96 | // Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!"); | 96 | // Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!"); |
97 | il.Emit(OpCodes.Call, typeof(Console).GetMethod | 97 | il.Emit(OpCodes.Call, typeof(Console).GetMethod |
98 | ("WriteLine", new Type[] { typeof(string) })); | 98 | ("WriteLine", new Type[] { typeof(string) })); |
99 | 99 | ||
100 | //il.EmitCall(OpCodes.Callvirt | 100 | //il.EmitCall(OpCodes.Callvirt |
101 | //il.Emit(OpCodes.Call, typeof(WorldAPI).GetMethod | 101 | //il.Emit(OpCodes.Call, typeof(WorldAPI).GetMethod |
102 | //("TestFunction")); | 102 | //("TestFunction")); |
103 | 103 | ||
104 | 104 | ||
105 | //il.ThrowException(typeof(NotSupportedException)); | 105 | //il.ThrowException(typeof(NotSupportedException)); |
106 | 106 | ||
107 | 107 | ||
108 | /* | 108 | /* |
109 | * CATCH | 109 | * CATCH |
110 | */ | 110 | */ |
111 | il.BeginCatchBlock(typeof(Exception)); | 111 | il.BeginCatchBlock(typeof(Exception)); |
112 | 112 | ||
113 | // Push "Hello World!" string to stack | 113 | // Push "Hello World!" string to stack |
114 | il.Emit(OpCodes.Ldstr, "Something went wrong: "); | 114 | il.Emit(OpCodes.Ldstr, "Something went wrong: "); |
115 | 115 | ||
116 | //call void [mscorlib]System.Console::WriteLine(string) | 116 | //call void [mscorlib]System.Console::WriteLine(string) |
117 | il.Emit(OpCodes.Call, typeof(Console).GetMethod | 117 | il.Emit(OpCodes.Call, typeof(Console).GetMethod |
118 | ("Write", new Type[] { typeof(string) })); | 118 | ("Write", new Type[] { typeof(string) })); |
119 | 119 | ||
120 | //callvirt instance string [mscorlib]System.Exception::get_Message() | 120 | //callvirt instance string [mscorlib]System.Exception::get_Message() |
121 | il.Emit(OpCodes.Callvirt, typeof(Exception).GetMethod | 121 | il.Emit(OpCodes.Callvirt, typeof(Exception).GetMethod |
122 | ("get_Message")); | 122 | ("get_Message")); |
123 | 123 | ||
124 | //call void [mscorlib]System.Console::WriteLine(string) | 124 | //call void [mscorlib]System.Console::WriteLine(string) |
125 | il.Emit(OpCodes.Call, typeof(Console).GetMethod | 125 | il.Emit(OpCodes.Call, typeof(Console).GetMethod |
126 | ("WriteLine", new Type[] { typeof(string) })); | 126 | ("WriteLine", new Type[] { typeof(string) })); |
127 | 127 | ||
128 | /* | 128 | /* |
129 | * END TRY | 129 | * END TRY |
130 | */ | 130 | */ |
131 | il.EndExceptionBlock(); | 131 | il.EndExceptionBlock(); |
132 | 132 | ||
133 | 133 | ||
134 | // Push "Return from current method, with return value if present" to stack | 134 | // Push "Return from current method, with return value if present" to stack |
135 | il.Emit(OpCodes.Ret); | 135 | il.Emit(OpCodes.Ret); |
136 | 136 | ||
137 | 137 | ||
138 | } | 138 | } |
139 | } | 139 | } |
140 | } | 140 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSL_CLRInterface.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSL_CLRInterface.cs index dc612ff..57bbf11 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSL_CLRInterface.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSL_CLRInterface.cs | |||
@@ -1,51 +1,51 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | 4 | ||
5 | namespace OpenSim.ScriptEngines.LSL | 5 | namespace OpenSim.ScriptEngines.LSL |
6 | { | 6 | { |
7 | public class LSL_CLRInterface | 7 | public class LSL_CLRInterface |
8 | { | 8 | { |
9 | public interface LSLScript | 9 | public interface LSLScript |
10 | { | 10 | { |
11 | //public virtual void Run(object arg) | 11 | //public virtual void Run(object arg) |
12 | //{ | 12 | //{ |
13 | //} | 13 | //} |
14 | //void Run(object arg); | 14 | //void Run(object arg); |
15 | 15 | ||
16 | void event_state_entry(object arg); | 16 | void event_state_entry(object arg); |
17 | //void event_state_exit(); | 17 | //void event_state_exit(); |
18 | void event_touch_start(object arg); | 18 | void event_touch_start(object arg); |
19 | //void event_touch(); | 19 | //void event_touch(); |
20 | //void event_touch_end(); | 20 | //void event_touch_end(); |
21 | //void event_collision_start(); | 21 | //void event_collision_start(); |
22 | //void event_collision(); | 22 | //void event_collision(); |
23 | //void event_collision_end(); | 23 | //void event_collision_end(); |
24 | //void event_land_collision_start(); | 24 | //void event_land_collision_start(); |
25 | //void event_land_collision(); | 25 | //void event_land_collision(); |
26 | //void event_land_collision_end(); | 26 | //void event_land_collision_end(); |
27 | //void event_timer(); | 27 | //void event_timer(); |
28 | //void event_listen(); | 28 | //void event_listen(); |
29 | //void event_on_rez(); | 29 | //void event_on_rez(); |
30 | //void event_sensor(); | 30 | //void event_sensor(); |
31 | //void event_no_sensor(); | 31 | //void event_no_sensor(); |
32 | //void event_control(); | 32 | //void event_control(); |
33 | //void event_money(); | 33 | //void event_money(); |
34 | //void event_email(); | 34 | //void event_email(); |
35 | //void event_at_target(); | 35 | //void event_at_target(); |
36 | //void event_not_at_target(); | 36 | //void event_not_at_target(); |
37 | //void event_at_rot_target(); | 37 | //void event_at_rot_target(); |
38 | //void event_not_at_rot_target(); | 38 | //void event_not_at_rot_target(); |
39 | //void event_run_time_permissions(); | 39 | //void event_run_time_permissions(); |
40 | //void event_changed(); | 40 | //void event_changed(); |
41 | //void event_attach(); | 41 | //void event_attach(); |
42 | //void event_dataserver(); | 42 | //void event_dataserver(); |
43 | //void event_link_message(); | 43 | //void event_link_message(); |
44 | //void event_moving_start(); | 44 | //void event_moving_start(); |
45 | //void event_moving_end(); | 45 | //void event_moving_end(); |
46 | //void event_object_rez(); | 46 | //void event_object_rez(); |
47 | //void event_remote_data(); | 47 | //void event_remote_data(); |
48 | //void event_http_response(); | 48 | //void event_http_response(); |
49 | } | 49 | } |
50 | } | 50 | } |
51 | } | 51 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Enums.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Enums.cs index edeccdd..b45abe0 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Enums.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Enums.cs | |||
@@ -1,485 +1,485 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | 4 | ||
5 | namespace OpenSim.ScriptEngines.LSL | 5 | namespace OpenSim.ScriptEngines.LSL |
6 | { | 6 | { |
7 | static class LSO_Enums | 7 | static class LSO_Enums |
8 | { | 8 | { |
9 | 9 | ||
10 | public enum Variable_Type_Codes | 10 | public enum Variable_Type_Codes |
11 | { | 11 | { |
12 | Void = 0, | 12 | Void = 0, |
13 | Integer = 1, | 13 | Integer = 1, |
14 | Float = 2, | 14 | Float = 2, |
15 | String = 3, | 15 | String = 3, |
16 | Key = 4, | 16 | Key = 4, |
17 | Vector = 5, | 17 | Vector = 5, |
18 | Rotation = 6, | 18 | Rotation = 6, |
19 | List = 7 | 19 | List = 7 |
20 | } | 20 | } |
21 | public enum Event_Mask_Values | 21 | public enum Event_Mask_Values |
22 | { | 22 | { |
23 | state_entry = 0, | 23 | state_entry = 0, |
24 | state_exit = 1, | 24 | state_exit = 1, |
25 | touch_start = 2, | 25 | touch_start = 2, |
26 | touch = 3, | 26 | touch = 3, |
27 | touch_end = 4, | 27 | touch_end = 4, |
28 | collision_start = 5, | 28 | collision_start = 5, |
29 | collision = 6, | 29 | collision = 6, |
30 | collision_end = 7, | 30 | collision_end = 7, |
31 | land_collision_start = 8, | 31 | land_collision_start = 8, |
32 | land_collision = 9, | 32 | land_collision = 9, |
33 | land_collision_end = 10, | 33 | land_collision_end = 10, |
34 | timer = 11, | 34 | timer = 11, |
35 | listen = 12, | 35 | listen = 12, |
36 | on_rez = 13, | 36 | on_rez = 13, |
37 | sensor = 14, | 37 | sensor = 14, |
38 | no_sensor = 15, | 38 | no_sensor = 15, |
39 | control = 16, | 39 | control = 16, |
40 | money = 17, | 40 | money = 17, |
41 | email = 18, | 41 | email = 18, |
42 | at_target = 19, | 42 | at_target = 19, |
43 | not_at_target = 20, | 43 | not_at_target = 20, |
44 | at_rot_target = 21, | 44 | at_rot_target = 21, |
45 | not_at_rot_target = 22, | 45 | not_at_rot_target = 22, |
46 | run_time_permissions = 23, | 46 | run_time_permissions = 23, |
47 | changed = 24, | 47 | changed = 24, |
48 | attach = 25, | 48 | attach = 25, |
49 | dataserver = 26, | 49 | dataserver = 26, |
50 | link_message = 27, | 50 | link_message = 27, |
51 | moving_start = 28, | 51 | moving_start = 28, |
52 | moving_end = 29, | 52 | moving_end = 29, |
53 | object_rez = 30, | 53 | object_rez = 30, |
54 | remote_data = 31, | 54 | remote_data = 31, |
55 | http_response = 32 | 55 | http_response = 32 |
56 | } | 56 | } |
57 | public enum Operation_Table | 57 | public enum Operation_Table |
58 | { | 58 | { |
59 | NOOP = 0x0, | 59 | NOOP = 0x0, |
60 | POP = 0x1, | 60 | POP = 0x1, |
61 | POPS = 0x2, | 61 | POPS = 0x2, |
62 | POPL = 0x3, | 62 | POPL = 0x3, |
63 | POPV = 0x4, | 63 | POPV = 0x4, |
64 | POPQ = 0x5, | 64 | POPQ = 0x5, |
65 | POPARG = 0x6, | 65 | POPARG = 0x6, |
66 | POPIP = 0x7, | 66 | POPIP = 0x7, |
67 | POPBP = 0x8, | 67 | POPBP = 0x8, |
68 | POPSP = 0x9, | 68 | POPSP = 0x9, |
69 | POPSLR = 0xa, | 69 | POPSLR = 0xa, |
70 | DUP = 0x20, | 70 | DUP = 0x20, |
71 | DUPS = 0x21, | 71 | DUPS = 0x21, |
72 | DUPL = 0x22, | 72 | DUPL = 0x22, |
73 | DUPV = 0x23, | 73 | DUPV = 0x23, |
74 | DUPQ = 0x24, | 74 | DUPQ = 0x24, |
75 | STORE = 0x30, | 75 | STORE = 0x30, |
76 | STORES = 0x31, | 76 | STORES = 0x31, |
77 | STOREL = 0x32, | 77 | STOREL = 0x32, |
78 | STOREV = 0x33, | 78 | STOREV = 0x33, |
79 | STOREQ = 0x34, | 79 | STOREQ = 0x34, |
80 | STOREG = 0x35, | 80 | STOREG = 0x35, |
81 | STOREGS = 0x36, | 81 | STOREGS = 0x36, |
82 | STOREGL = 0x37, | 82 | STOREGL = 0x37, |
83 | STOREGV = 0x38, | 83 | STOREGV = 0x38, |
84 | STOREGQ = 0x39, | 84 | STOREGQ = 0x39, |
85 | LOADP = 0x3a, | 85 | LOADP = 0x3a, |
86 | LOADSP = 0x3b, | 86 | LOADSP = 0x3b, |
87 | LOADLP = 0x3c, | 87 | LOADLP = 0x3c, |
88 | LOADVP = 0x3d, | 88 | LOADVP = 0x3d, |
89 | LOADQP = 0x3e, | 89 | LOADQP = 0x3e, |
90 | LOADGP = 0x3f, | 90 | LOADGP = 0x3f, |
91 | LOADGSP = 0x40, | 91 | LOADGSP = 0x40, |
92 | LOADGLP = 0x41, | 92 | LOADGLP = 0x41, |
93 | LOADGVP = 0x42, | 93 | LOADGVP = 0x42, |
94 | LOADGQP = 0x43, | 94 | LOADGQP = 0x43, |
95 | PUSH = 0x50, | 95 | PUSH = 0x50, |
96 | PUSHS = 0x51, | 96 | PUSHS = 0x51, |
97 | PUSHL = 0x52, | 97 | PUSHL = 0x52, |
98 | PUSHV = 0x53, | 98 | PUSHV = 0x53, |
99 | PUSHQ = 0x54, | 99 | PUSHQ = 0x54, |
100 | PUSHG = 0x55, | 100 | PUSHG = 0x55, |
101 | PUSHGS = 0x56, | 101 | PUSHGS = 0x56, |
102 | PUSHGL = 0x57, | 102 | PUSHGL = 0x57, |
103 | PUSHGV = 0x58, | 103 | PUSHGV = 0x58, |
104 | PUSHGQ = 0x59, | 104 | PUSHGQ = 0x59, |
105 | PUSHIP = 0x5a, | 105 | PUSHIP = 0x5a, |
106 | PUSHBP = 0x5b, | 106 | PUSHBP = 0x5b, |
107 | PUSHSP = 0x5c, | 107 | PUSHSP = 0x5c, |
108 | PUSHARGB = 0x5d, | 108 | PUSHARGB = 0x5d, |
109 | PUSHARGI = 0x5e, | 109 | PUSHARGI = 0x5e, |
110 | PUSHARGF = 0x5f, | 110 | PUSHARGF = 0x5f, |
111 | PUSHARGS = 0x60, | 111 | PUSHARGS = 0x60, |
112 | PUSHARGV = 0x61, | 112 | PUSHARGV = 0x61, |
113 | PUSHARGQ = 0x62, | 113 | PUSHARGQ = 0x62, |
114 | PUSHE = 0x63, | 114 | PUSHE = 0x63, |
115 | PUSHEV = 0x64, | 115 | PUSHEV = 0x64, |
116 | PUSHEQ = 0x65, | 116 | PUSHEQ = 0x65, |
117 | PUSHARGE = 0x66, | 117 | PUSHARGE = 0x66, |
118 | ADD = 0x70, | 118 | ADD = 0x70, |
119 | SUB = 0x71, | 119 | SUB = 0x71, |
120 | MUL = 0x72, | 120 | MUL = 0x72, |
121 | DIV = 0x73, | 121 | DIV = 0x73, |
122 | MOD = 0x74, | 122 | MOD = 0x74, |
123 | EQ = 0x75, | 123 | EQ = 0x75, |
124 | NEQ = 0x76, | 124 | NEQ = 0x76, |
125 | LEQ = 0x77, | 125 | LEQ = 0x77, |
126 | GEQ = 0x78, | 126 | GEQ = 0x78, |
127 | LESS = 0x79, | 127 | LESS = 0x79, |
128 | GREATER = 0x7a, | 128 | GREATER = 0x7a, |
129 | BITAND = 0x7b, | 129 | BITAND = 0x7b, |
130 | BITOR = 0x7c, | 130 | BITOR = 0x7c, |
131 | BITXOR = 0x7d, | 131 | BITXOR = 0x7d, |
132 | BOOLAND = 0x7e, | 132 | BOOLAND = 0x7e, |
133 | BOOLOR = 0x7f, | 133 | BOOLOR = 0x7f, |
134 | NEG = 0x80, | 134 | NEG = 0x80, |
135 | BITNOT = 0x81, | 135 | BITNOT = 0x81, |
136 | BOOLNOT = 0x82, | 136 | BOOLNOT = 0x82, |
137 | JUMP = 0x90, | 137 | JUMP = 0x90, |
138 | JUMPIF = 0x91, | 138 | JUMPIF = 0x91, |
139 | JUMPNIF = 0x92, | 139 | JUMPNIF = 0x92, |
140 | STATE = 0x93, | 140 | STATE = 0x93, |
141 | CALL = 0x94, | 141 | CALL = 0x94, |
142 | RETURN = 0x95, | 142 | RETURN = 0x95, |
143 | CAST = 0xa0, | 143 | CAST = 0xa0, |
144 | STACKTOS = 0xb0, | 144 | STACKTOS = 0xb0, |
145 | STACKTOL = 0xb1, | 145 | STACKTOL = 0xb1, |
146 | PRINT = 0xc0, | 146 | PRINT = 0xc0, |
147 | CALLLIB = 0xd0, | 147 | CALLLIB = 0xd0, |
148 | CALLLIB_TWO_BYTE = 0xd1, | 148 | CALLLIB_TWO_BYTE = 0xd1, |
149 | SHL = 0xe0, | 149 | SHL = 0xe0, |
150 | SHR = 0xe1 | 150 | SHR = 0xe1 |
151 | } | 151 | } |
152 | public enum BuiltIn_Functions | 152 | public enum BuiltIn_Functions |
153 | { | 153 | { |
154 | llSin = 0, | 154 | llSin = 0, |
155 | llCos = 1, | 155 | llCos = 1, |
156 | llTan = 2, | 156 | llTan = 2, |
157 | llAtan2 = 3, | 157 | llAtan2 = 3, |
158 | llSqrt = 4, | 158 | llSqrt = 4, |
159 | llPow = 5, | 159 | llPow = 5, |
160 | llAbs = 6, | 160 | llAbs = 6, |
161 | llFabs = 7, | 161 | llFabs = 7, |
162 | llFrand = 8, | 162 | llFrand = 8, |
163 | llFloor = 9, | 163 | llFloor = 9, |
164 | llCeil = 10, | 164 | llCeil = 10, |
165 | llRound = 11, | 165 | llRound = 11, |
166 | llVecMag = 12, | 166 | llVecMag = 12, |
167 | llVecNorm = 13, | 167 | llVecNorm = 13, |
168 | llVecDist = 14, | 168 | llVecDist = 14, |
169 | llRot2Euler = 15, | 169 | llRot2Euler = 15, |
170 | llEuler2Rot = 16, | 170 | llEuler2Rot = 16, |
171 | llAxes2Rot = 17, | 171 | llAxes2Rot = 17, |
172 | llRot2Fwd = 18, | 172 | llRot2Fwd = 18, |
173 | llRot2Left = 19, | 173 | llRot2Left = 19, |
174 | llRot2Up = 20, | 174 | llRot2Up = 20, |
175 | llRotBetween = 21, | 175 | llRotBetween = 21, |
176 | llWhisper = 22, | 176 | llWhisper = 22, |
177 | llSay = 23, | 177 | llSay = 23, |
178 | llShout = 24, | 178 | llShout = 24, |
179 | llListen = 25, | 179 | llListen = 25, |
180 | llListenControl = 26, | 180 | llListenControl = 26, |
181 | llListenRemove = 27, | 181 | llListenRemove = 27, |
182 | llSensor = 28, | 182 | llSensor = 28, |
183 | llSensorRepeat = 29, | 183 | llSensorRepeat = 29, |
184 | llSensorRemove = 30, | 184 | llSensorRemove = 30, |
185 | llDetectedName = 31, | 185 | llDetectedName = 31, |
186 | llDetectedKey = 32, | 186 | llDetectedKey = 32, |
187 | llDetectedOwner = 33, | 187 | llDetectedOwner = 33, |
188 | llDetectedType = 34, | 188 | llDetectedType = 34, |
189 | llDetectedPos = 35, | 189 | llDetectedPos = 35, |
190 | llDetectedVel = 36, | 190 | llDetectedVel = 36, |
191 | llDetectedGrab = 37, | 191 | llDetectedGrab = 37, |
192 | llDetectedRot = 38, | 192 | llDetectedRot = 38, |
193 | llDetectedGroup = 39, | 193 | llDetectedGroup = 39, |
194 | llDetectedLinkNumber = 40, | 194 | llDetectedLinkNumber = 40, |
195 | llDie = 41, | 195 | llDie = 41, |
196 | llGround = 42, | 196 | llGround = 42, |
197 | llCloud = 43, | 197 | llCloud = 43, |
198 | llWind = 44, | 198 | llWind = 44, |
199 | llSetStatus = 45, | 199 | llSetStatus = 45, |
200 | llGetStatus = 46, | 200 | llGetStatus = 46, |
201 | llSetScale = 47, | 201 | llSetScale = 47, |
202 | llGetScale = 48, | 202 | llGetScale = 48, |
203 | llSetColor = 49, | 203 | llSetColor = 49, |
204 | llGetAlpha = 50, | 204 | llGetAlpha = 50, |
205 | llSetAlpha = 51, | 205 | llSetAlpha = 51, |
206 | llGetColor = 52, | 206 | llGetColor = 52, |
207 | llSetTexture = 53, | 207 | llSetTexture = 53, |
208 | llScaleTexture = 54, | 208 | llScaleTexture = 54, |
209 | llOffsetTexture = 55, | 209 | llOffsetTexture = 55, |
210 | llRotateTexture = 56, | 210 | llRotateTexture = 56, |
211 | llGetTexture = 57, | 211 | llGetTexture = 57, |
212 | llSetPos = 58, | 212 | llSetPos = 58, |
213 | llGetPos = 59, | 213 | llGetPos = 59, |
214 | llGetLocalPos = 60, | 214 | llGetLocalPos = 60, |
215 | llSetRot = 61, | 215 | llSetRot = 61, |
216 | llGetRot = 62, | 216 | llGetRot = 62, |
217 | llGetLocalRot = 63, | 217 | llGetLocalRot = 63, |
218 | llSetForce = 64, | 218 | llSetForce = 64, |
219 | llGetForce = 65, | 219 | llGetForce = 65, |
220 | llTarget = 66, | 220 | llTarget = 66, |
221 | llTargetRemove = 67, | 221 | llTargetRemove = 67, |
222 | llRotTarget = 68, | 222 | llRotTarget = 68, |
223 | llRotTargetRemove = 69, | 223 | llRotTargetRemove = 69, |
224 | llMoveToTarget = 70, | 224 | llMoveToTarget = 70, |
225 | llStopMoveToTarget = 71, | 225 | llStopMoveToTarget = 71, |
226 | llApplyImpulse = 72, | 226 | llApplyImpulse = 72, |
227 | llApplyRotationalImpulse = 73, | 227 | llApplyRotationalImpulse = 73, |
228 | llSetTorque = 74, | 228 | llSetTorque = 74, |
229 | llGetTorque = 75, | 229 | llGetTorque = 75, |
230 | llSetForceAndTorque = 76, | 230 | llSetForceAndTorque = 76, |
231 | llGetVel = 77, | 231 | llGetVel = 77, |
232 | llGetAccel = 78, | 232 | llGetAccel = 78, |
233 | llGetOmega = 79, | 233 | llGetOmega = 79, |
234 | llGetTimeOfDay = 80, | 234 | llGetTimeOfDay = 80, |
235 | llGetWallclock = 81, | 235 | llGetWallclock = 81, |
236 | llGetTime = 82, | 236 | llGetTime = 82, |
237 | llResetTime = 83, | 237 | llResetTime = 83, |
238 | llGetAndResetTime = 84, | 238 | llGetAndResetTime = 84, |
239 | llSound = 85, | 239 | llSound = 85, |
240 | llPlaySound = 86, | 240 | llPlaySound = 86, |
241 | llLoopSound = 87, | 241 | llLoopSound = 87, |
242 | llLoopSoundMaster = 88, | 242 | llLoopSoundMaster = 88, |
243 | llLoopSoundSlave = 89, | 243 | llLoopSoundSlave = 89, |
244 | llPlaySoundSlave = 90, | 244 | llPlaySoundSlave = 90, |
245 | llTriggerSound = 91, | 245 | llTriggerSound = 91, |
246 | llStopSound = 92, | 246 | llStopSound = 92, |
247 | llPreloadSound = 93, | 247 | llPreloadSound = 93, |
248 | llGetSubString = 94, | 248 | llGetSubString = 94, |
249 | llDeleteSubString = 95, | 249 | llDeleteSubString = 95, |
250 | llInsertString = 96, | 250 | llInsertString = 96, |
251 | llToUpper = 97, | 251 | llToUpper = 97, |
252 | llToLower = 98, | 252 | llToLower = 98, |
253 | llGiveMoney = 99, | 253 | llGiveMoney = 99, |
254 | llMakeExplosion = 100, | 254 | llMakeExplosion = 100, |
255 | llMakeFountain = 101, | 255 | llMakeFountain = 101, |
256 | llMakeSmoke = 102, | 256 | llMakeSmoke = 102, |
257 | llMakeFire = 103, | 257 | llMakeFire = 103, |
258 | llRezObject = 104, | 258 | llRezObject = 104, |
259 | llLookAt = 105, | 259 | llLookAt = 105, |
260 | llStopLookAt = 106, | 260 | llStopLookAt = 106, |
261 | llSetTimerEvent = 107, | 261 | llSetTimerEvent = 107, |
262 | llSleep = 108, | 262 | llSleep = 108, |
263 | llGetMass = 109, | 263 | llGetMass = 109, |
264 | llCollisionFilter = 110, | 264 | llCollisionFilter = 110, |
265 | llTakeControls = 111, | 265 | llTakeControls = 111, |
266 | llReleaseControls = 112, | 266 | llReleaseControls = 112, |
267 | llAttachToAvatar = 113, | 267 | llAttachToAvatar = 113, |
268 | llDetachFromAvatar = 114, | 268 | llDetachFromAvatar = 114, |
269 | llTakeCamera = 115, | 269 | llTakeCamera = 115, |
270 | llReleaseCamera = 116, | 270 | llReleaseCamera = 116, |
271 | llGetOwner = 117, | 271 | llGetOwner = 117, |
272 | llInstantMessage = 118, | 272 | llInstantMessage = 118, |
273 | llEmail = 119, | 273 | llEmail = 119, |
274 | llGetNextEmail = 120, | 274 | llGetNextEmail = 120, |
275 | llGetKey = 121, | 275 | llGetKey = 121, |
276 | llSetBuoyancy = 122, | 276 | llSetBuoyancy = 122, |
277 | llSetHoverHeight = 123, | 277 | llSetHoverHeight = 123, |
278 | llStopHover = 124, | 278 | llStopHover = 124, |
279 | llMinEventDelay = 125, | 279 | llMinEventDelay = 125, |
280 | llSoundPreload = 126, | 280 | llSoundPreload = 126, |
281 | llRotLookAt = 127, | 281 | llRotLookAt = 127, |
282 | llStringLength = 128, | 282 | llStringLength = 128, |
283 | llStartAnimation = 129, | 283 | llStartAnimation = 129, |
284 | llStopAnimation = 130, | 284 | llStopAnimation = 130, |
285 | llPointAt = 131, | 285 | llPointAt = 131, |
286 | llStopPointAt = 132, | 286 | llStopPointAt = 132, |
287 | llTargetOmega = 133, | 287 | llTargetOmega = 133, |
288 | llGetStartParameter = 134, | 288 | llGetStartParameter = 134, |
289 | llGodLikeRezObject = 135, | 289 | llGodLikeRezObject = 135, |
290 | llRequestPermissions = 136, | 290 | llRequestPermissions = 136, |
291 | llGetPermissionsKey = 137, | 291 | llGetPermissionsKey = 137, |
292 | llGetPermissions = 138, | 292 | llGetPermissions = 138, |
293 | llGetLinkNumber = 139, | 293 | llGetLinkNumber = 139, |
294 | llSetLinkColor = 140, | 294 | llSetLinkColor = 140, |
295 | llCreateLink = 141, | 295 | llCreateLink = 141, |
296 | llBreakLink = 142, | 296 | llBreakLink = 142, |
297 | llBreakAllLinks = 143, | 297 | llBreakAllLinks = 143, |
298 | llGetLinkKey = 144, | 298 | llGetLinkKey = 144, |
299 | llGetLinkName = 145, | 299 | llGetLinkName = 145, |
300 | llGetInventoryNumber = 146, | 300 | llGetInventoryNumber = 146, |
301 | llGetInventoryName = 147, | 301 | llGetInventoryName = 147, |
302 | llSetScriptState = 148, | 302 | llSetScriptState = 148, |
303 | llGetEnergy = 149, | 303 | llGetEnergy = 149, |
304 | llGiveInventory = 150, | 304 | llGiveInventory = 150, |
305 | llRemoveInventory = 151, | 305 | llRemoveInventory = 151, |
306 | llSetText = 152, | 306 | llSetText = 152, |
307 | llWater = 153, | 307 | llWater = 153, |
308 | llPassTouches = 154, | 308 | llPassTouches = 154, |
309 | llRequestAgentData = 155, | 309 | llRequestAgentData = 155, |
310 | llRequestInventoryData = 156, | 310 | llRequestInventoryData = 156, |
311 | llSetDamage = 157, | 311 | llSetDamage = 157, |
312 | llTeleportAgentHome = 158, | 312 | llTeleportAgentHome = 158, |
313 | llModifyLand = 159, | 313 | llModifyLand = 159, |
314 | llCollisionSound = 160, | 314 | llCollisionSound = 160, |
315 | llCollisionSprite = 161, | 315 | llCollisionSprite = 161, |
316 | llGetAnimation = 162, | 316 | llGetAnimation = 162, |
317 | llResetScript = 163, | 317 | llResetScript = 163, |
318 | llMessageLinked = 164, | 318 | llMessageLinked = 164, |
319 | llPushObject = 165, | 319 | llPushObject = 165, |
320 | llPassCollisions = 166, | 320 | llPassCollisions = 166, |
321 | llGetScriptName = 167, | 321 | llGetScriptName = 167, |
322 | llGetNumberOfSides = 168, | 322 | llGetNumberOfSides = 168, |
323 | llAxisAngle2Rot = 169, | 323 | llAxisAngle2Rot = 169, |
324 | llRot2Axis = 170, | 324 | llRot2Axis = 170, |
325 | llRot2Angle = 171, | 325 | llRot2Angle = 171, |
326 | llAcos = 172, | 326 | llAcos = 172, |
327 | llAsin = 173, | 327 | llAsin = 173, |
328 | llAngleBetween = 174, | 328 | llAngleBetween = 174, |
329 | llGetInventoryKey = 175, | 329 | llGetInventoryKey = 175, |
330 | llAllowInventoryDrop = 176, | 330 | llAllowInventoryDrop = 176, |
331 | llGetSunDirection = 177, | 331 | llGetSunDirection = 177, |
332 | llGetTextureOffset = 178, | 332 | llGetTextureOffset = 178, |
333 | llGetTextureScale = 179, | 333 | llGetTextureScale = 179, |
334 | llGetTextureRot = 180, | 334 | llGetTextureRot = 180, |
335 | llSubStringIndex = 181, | 335 | llSubStringIndex = 181, |
336 | llGetOwnerKey = 182, | 336 | llGetOwnerKey = 182, |
337 | llGetCenterOfMass = 183, | 337 | llGetCenterOfMass = 183, |
338 | llListSort = 184, | 338 | llListSort = 184, |
339 | llGetListLength = 185, | 339 | llGetListLength = 185, |
340 | llList2Integer = 186, | 340 | llList2Integer = 186, |
341 | llList2Float = 187, | 341 | llList2Float = 187, |
342 | llList2String = 188, | 342 | llList2String = 188, |
343 | llList2Key = 189, | 343 | llList2Key = 189, |
344 | llList2Vector = 190, | 344 | llList2Vector = 190, |
345 | llList2Rot = 191, | 345 | llList2Rot = 191, |
346 | llList2List = 192, | 346 | llList2List = 192, |
347 | llDeleteSubList = 193, | 347 | llDeleteSubList = 193, |
348 | llGetListEntryType = 194, | 348 | llGetListEntryType = 194, |
349 | llList2CSV = 195, | 349 | llList2CSV = 195, |
350 | llCSV2List = 196, | 350 | llCSV2List = 196, |
351 | llListRandomize = 197, | 351 | llListRandomize = 197, |
352 | llList2ListStrided = 198, | 352 | llList2ListStrided = 198, |
353 | llGetRegionCorner = 199, | 353 | llGetRegionCorner = 199, |
354 | llListInsertList = 200, | 354 | llListInsertList = 200, |
355 | llListFindList = 201, | 355 | llListFindList = 201, |
356 | llGetObjectName = 202, | 356 | llGetObjectName = 202, |
357 | llSetObjectName = 203, | 357 | llSetObjectName = 203, |
358 | llGetDate = 204, | 358 | llGetDate = 204, |
359 | llEdgeOfWorld = 205, | 359 | llEdgeOfWorld = 205, |
360 | llGetAgentInfo = 206, | 360 | llGetAgentInfo = 206, |
361 | llAdjustSoundVolume = 207, | 361 | llAdjustSoundVolume = 207, |
362 | llSetSoundQueueing = 208, | 362 | llSetSoundQueueing = 208, |
363 | llSetSoundRadius = 209, | 363 | llSetSoundRadius = 209, |
364 | llKey2Name = 210, | 364 | llKey2Name = 210, |
365 | llSetTextureAnim = 211, | 365 | llSetTextureAnim = 211, |
366 | llTriggerSoundLimited = 212, | 366 | llTriggerSoundLimited = 212, |
367 | llEjectFromLand = 213, | 367 | llEjectFromLand = 213, |
368 | llParseString2List = 214, | 368 | llParseString2List = 214, |
369 | llOverMyLand = 215, | 369 | llOverMyLand = 215, |
370 | llGetLandOwnerAt = 216, | 370 | llGetLandOwnerAt = 216, |
371 | llGetNotecardLine = 217, | 371 | llGetNotecardLine = 217, |
372 | llGetAgentSize = 218, | 372 | llGetAgentSize = 218, |
373 | llSameGroup = 219, | 373 | llSameGroup = 219, |
374 | llUnSit = 220, | 374 | llUnSit = 220, |
375 | llGroundSlope = 221, | 375 | llGroundSlope = 221, |
376 | llGroundNormal = 222, | 376 | llGroundNormal = 222, |
377 | llGroundContour = 223, | 377 | llGroundContour = 223, |
378 | llGetAttached = 224, | 378 | llGetAttached = 224, |
379 | llGetFreeMemory = 225, | 379 | llGetFreeMemory = 225, |
380 | llGetRegionName = 226, | 380 | llGetRegionName = 226, |
381 | llGetRegionTimeDilation = 227, | 381 | llGetRegionTimeDilation = 227, |
382 | llGetRegionFPS = 228, | 382 | llGetRegionFPS = 228, |
383 | llParticleSystem = 229, | 383 | llParticleSystem = 229, |
384 | llGroundRepel = 230, | 384 | llGroundRepel = 230, |
385 | llGiveInventoryList = 231, | 385 | llGiveInventoryList = 231, |
386 | llSetVehicleType = 232, | 386 | llSetVehicleType = 232, |
387 | llSetVehicleFloatParam = 233, | 387 | llSetVehicleFloatParam = 233, |
388 | llSetVehicleVectorParam = 234, | 388 | llSetVehicleVectorParam = 234, |
389 | llSetVehicleRotationParam = 235, | 389 | llSetVehicleRotationParam = 235, |
390 | llSetVehicleFlags = 236, | 390 | llSetVehicleFlags = 236, |
391 | llRemoveVehicleFlags = 237, | 391 | llRemoveVehicleFlags = 237, |
392 | llSitTarget = 238, | 392 | llSitTarget = 238, |
393 | llAvatarOnSitTarget = 239, | 393 | llAvatarOnSitTarget = 239, |
394 | llAddToLandPassList = 240, | 394 | llAddToLandPassList = 240, |
395 | llSetTouchText = 241, | 395 | llSetTouchText = 241, |
396 | llSetSitText = 242, | 396 | llSetSitText = 242, |
397 | llSetCameraEyeOffset = 243, | 397 | llSetCameraEyeOffset = 243, |
398 | llSetCameraAtOffset = 244, | 398 | llSetCameraAtOffset = 244, |
399 | llDumpList2String = 245, | 399 | llDumpList2String = 245, |
400 | llScriptDanger = 246, | 400 | llScriptDanger = 246, |
401 | llDialog = 247, | 401 | llDialog = 247, |
402 | llVolumeDetect = 248, | 402 | llVolumeDetect = 248, |
403 | llResetOtherScript = 249, | 403 | llResetOtherScript = 249, |
404 | llGetScriptState = 250, | 404 | llGetScriptState = 250, |
405 | llRemoteLoadScript = 251, | 405 | llRemoteLoadScript = 251, |
406 | llSetRemoteScriptAccessPin = 252, | 406 | llSetRemoteScriptAccessPin = 252, |
407 | llRemoteLoadScriptPin = 253, | 407 | llRemoteLoadScriptPin = 253, |
408 | llOpenRemoteDataChannel = 254, | 408 | llOpenRemoteDataChannel = 254, |
409 | llSendRemoteData = 255, | 409 | llSendRemoteData = 255, |
410 | llRemoteDataReply = 256, | 410 | llRemoteDataReply = 256, |
411 | llCloseRemoteDataChannel = 257, | 411 | llCloseRemoteDataChannel = 257, |
412 | llMD5String = 258, | 412 | llMD5String = 258, |
413 | llSetPrimitiveParams = 259, | 413 | llSetPrimitiveParams = 259, |
414 | llStringToBase64 = 260, | 414 | llStringToBase64 = 260, |
415 | llBase64ToString = 261, | 415 | llBase64ToString = 261, |
416 | llXorBase64Strings = 262, | 416 | llXorBase64Strings = 262, |
417 | llRemoteDataSetRegion = 263, | 417 | llRemoteDataSetRegion = 263, |
418 | llLog10 = 264, | 418 | llLog10 = 264, |
419 | llLog = 265, | 419 | llLog = 265, |
420 | llGetAnimationList = 266, | 420 | llGetAnimationList = 266, |
421 | llSetParcelMusicURL = 267, | 421 | llSetParcelMusicURL = 267, |
422 | llGetRootPosition = 268, | 422 | llGetRootPosition = 268, |
423 | llGetRootRotation = 269, | 423 | llGetRootRotation = 269, |
424 | llGetObjectDesc = 270, | 424 | llGetObjectDesc = 270, |
425 | llSetObjectDesc = 271, | 425 | llSetObjectDesc = 271, |
426 | llGetCreator = 272, | 426 | llGetCreator = 272, |
427 | llGetTimestamp = 273, | 427 | llGetTimestamp = 273, |
428 | llSetLinkAlpha = 274, | 428 | llSetLinkAlpha = 274, |
429 | llGetNumberOfPrims = 275, | 429 | llGetNumberOfPrims = 275, |
430 | llGetNumberOfNotecardLines = 276, | 430 | llGetNumberOfNotecardLines = 276, |
431 | llGetBoundingBox = 277, | 431 | llGetBoundingBox = 277, |
432 | llGetGeometricCenter = 278, | 432 | llGetGeometricCenter = 278, |
433 | llGetPrimitiveParams = 279, | 433 | llGetPrimitiveParams = 279, |
434 | llIntegerToBase64 = 280, | 434 | llIntegerToBase64 = 280, |
435 | llBase64ToInteger = 281, | 435 | llBase64ToInteger = 281, |
436 | llGetGMTclock = 282, | 436 | llGetGMTclock = 282, |
437 | llGetSimulatorHostname = 283, | 437 | llGetSimulatorHostname = 283, |
438 | llSetLocalRot = 284, | 438 | llSetLocalRot = 284, |
439 | llParseStringKeepNulls = 285, | 439 | llParseStringKeepNulls = 285, |
440 | llRezAtRoot = 286, | 440 | llRezAtRoot = 286, |
441 | llGetObjectPermMask = 287, | 441 | llGetObjectPermMask = 287, |
442 | llSetObjectPermMask = 288, | 442 | llSetObjectPermMask = 288, |
443 | llGetInventoryPermMask = 289, | 443 | llGetInventoryPermMask = 289, |
444 | llSetInventoryPermMask = 290, | 444 | llSetInventoryPermMask = 290, |
445 | llGetInventoryCreator = 291, | 445 | llGetInventoryCreator = 291, |
446 | llOwnerSay = 292, | 446 | llOwnerSay = 292, |
447 | llRequestSimulatorData = 293, | 447 | llRequestSimulatorData = 293, |
448 | llForceMouselook = 294, | 448 | llForceMouselook = 294, |
449 | llGetObjectMass = 295, | 449 | llGetObjectMass = 295, |
450 | llListReplaceList = 296, | 450 | llListReplaceList = 296, |
451 | llLoadURL = 297, | 451 | llLoadURL = 297, |
452 | llParcelMediaCommandList = 298, | 452 | llParcelMediaCommandList = 298, |
453 | llParcelMediaQuery = 299, | 453 | llParcelMediaQuery = 299, |
454 | llModPow = 300, | 454 | llModPow = 300, |
455 | llGetInventoryType = 301, | 455 | llGetInventoryType = 301, |
456 | llSetPayPrice = 302, | 456 | llSetPayPrice = 302, |
457 | llGetCameraPos = 303, | 457 | llGetCameraPos = 303, |
458 | llGetCameraRot = 304, | 458 | llGetCameraRot = 304, |
459 | llSetPrimURL = 305, | 459 | llSetPrimURL = 305, |
460 | llRefreshPrimURL = 306, | 460 | llRefreshPrimURL = 306, |
461 | llEscapeURL = 307, | 461 | llEscapeURL = 307, |
462 | llUnescapeURL = 308, | 462 | llUnescapeURL = 308, |
463 | llMapDestination = 309, | 463 | llMapDestination = 309, |
464 | llAddToLandBanList = 310, | 464 | llAddToLandBanList = 310, |
465 | llRemoveFromLandPassList = 311, | 465 | llRemoveFromLandPassList = 311, |
466 | llRemoveFromLandBanList = 312, | 466 | llRemoveFromLandBanList = 312, |
467 | llSetCameraParams = 313, | 467 | llSetCameraParams = 313, |
468 | llClearCameraParams = 314, | 468 | llClearCameraParams = 314, |
469 | llListStatistics = 315, | 469 | llListStatistics = 315, |
470 | llGetUnixTime = 316, | 470 | llGetUnixTime = 316, |
471 | llGetParcelFlags = 317, | 471 | llGetParcelFlags = 317, |
472 | llGetRegionFlags = 318, | 472 | llGetRegionFlags = 318, |
473 | llXorBase64StringsCorrect = 319, | 473 | llXorBase64StringsCorrect = 319, |
474 | llHTTPRequest = 320, | 474 | llHTTPRequest = 320, |
475 | llResetLandBanList = 321, | 475 | llResetLandBanList = 321, |
476 | llResetLandPassList = 322, | 476 | llResetLandPassList = 322, |
477 | llGetParcelPrimCount = 323, | 477 | llGetParcelPrimCount = 323, |
478 | llGetParcelPrimOwners = 324, | 478 | llGetParcelPrimOwners = 324, |
479 | llGetObjectPrimCount = 325, | 479 | llGetObjectPrimCount = 325, |
480 | llGetParcelMaxPrims = 326, | 480 | llGetParcelMaxPrims = 326, |
481 | llGetParcelDetails = 327 | 481 | llGetParcelDetails = 327 |
482 | } | 482 | } |
483 | 483 | ||
484 | } | 484 | } |
485 | } | 485 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Parser.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Parser.cs index 2da1189..ebe4465 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Parser.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Parser.cs | |||
@@ -1,608 +1,608 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using System.IO; | 4 | using System.IO; |
5 | using System.Reflection; | 5 | using System.Reflection; |
6 | using System.Reflection.Emit; | 6 | using System.Reflection.Emit; |
7 | using OpenSim.Region.Scripting; | 7 | using OpenSim.Region.Scripting; |
8 | 8 | ||
9 | namespace OpenSim.ScriptEngines.LSL | 9 | namespace OpenSim.ScriptEngines.LSL |
10 | { | 10 | { |
11 | class LSO_Parser | 11 | class LSO_Parser |
12 | { | 12 | { |
13 | private bool Debug = true; | 13 | private bool Debug = true; |
14 | private FileStream fs; | 14 | private FileStream fs; |
15 | private BinaryReader br; | 15 | private BinaryReader br; |
16 | private LSO_Struct.Header myHeader; | 16 | private LSO_Struct.Header myHeader; |
17 | 17 | ||
18 | private TypeBuilder typeBuilder; | 18 | private TypeBuilder typeBuilder; |
19 | private ScriptInfo WorldAPI; | 19 | private ScriptInfo WorldAPI; |
20 | 20 | ||
21 | /// <summary> | 21 | /// <summary> |
22 | /// Parse LSO file. | 22 | /// Parse LSO file. |
23 | /// Reads LSO ByteCode into memory structures. | 23 | /// Reads LSO ByteCode into memory structures. |
24 | /// TODO: What else does it do? | 24 | /// TODO: What else does it do? |
25 | /// </summary> | 25 | /// </summary> |
26 | /// <param name="FileName">FileName of LSO ByteCode file</param> | 26 | /// <param name="FileName">FileName of LSO ByteCode file</param> |
27 | public void ParseFile(string FileName, ScriptInfo _WorldAPI, ref TypeBuilder _typeBuilder) | 27 | public void ParseFile(string FileName, ScriptInfo _WorldAPI, ref TypeBuilder _typeBuilder) |
28 | { | 28 | { |
29 | typeBuilder = _typeBuilder; | 29 | typeBuilder = _typeBuilder; |
30 | WorldAPI = _WorldAPI; | 30 | WorldAPI = _WorldAPI; |
31 | // Open | 31 | // Open |
32 | SendToDebug("Opening filename: " + FileName); | 32 | SendToDebug("Opening filename: " + FileName); |
33 | fs = File.Open(FileName, FileMode.Open, FileAccess.Read, FileShare.Read); | 33 | fs = File.Open(FileName, FileMode.Open, FileAccess.Read, FileShare.Read); |
34 | br = new BinaryReader(fs, Encoding.BigEndianUnicode); | 34 | br = new BinaryReader(fs, Encoding.BigEndianUnicode); |
35 | 35 | ||
36 | 36 | ||
37 | // The LSO Format consist of 6 major blocks: header, statics, functions, states, heap, and stack. | 37 | // The LSO Format consist of 6 major blocks: header, statics, functions, states, heap, and stack. |
38 | 38 | ||
39 | 39 | ||
40 | // HEADER BLOCK | 40 | // HEADER BLOCK |
41 | SendToDebug("Reading HEADER BLOCK at: 0"); | 41 | SendToDebug("Reading HEADER BLOCK at: 0"); |
42 | fs.Seek(0, SeekOrigin.Begin); | 42 | fs.Seek(0, SeekOrigin.Begin); |
43 | myHeader = new LSO_Struct.Header(); | 43 | myHeader = new LSO_Struct.Header(); |
44 | myHeader.TM = BitConverter.ToUInt32(br_read(4), 0); | 44 | myHeader.TM = BitConverter.ToUInt32(br_read(4), 0); |
45 | myHeader.IP = BitConverter.ToUInt32(br_read(4), 0); | 45 | myHeader.IP = BitConverter.ToUInt32(br_read(4), 0); |
46 | myHeader.VN = BitConverter.ToUInt32(br_read(4), 0); | 46 | myHeader.VN = BitConverter.ToUInt32(br_read(4), 0); |
47 | myHeader.BP = BitConverter.ToUInt32(br_read(4), 0); | 47 | myHeader.BP = BitConverter.ToUInt32(br_read(4), 0); |
48 | myHeader.SP = BitConverter.ToUInt32(br_read(4), 0); | 48 | myHeader.SP = BitConverter.ToUInt32(br_read(4), 0); |
49 | myHeader.HR = BitConverter.ToUInt32(br_read(4), 0); | 49 | myHeader.HR = BitConverter.ToUInt32(br_read(4), 0); |
50 | myHeader.HP = BitConverter.ToUInt32(br_read(4), 0); | 50 | myHeader.HP = BitConverter.ToUInt32(br_read(4), 0); |
51 | myHeader.CS = BitConverter.ToUInt32(br_read(4), 0); | 51 | myHeader.CS = BitConverter.ToUInt32(br_read(4), 0); |
52 | myHeader.NS = BitConverter.ToUInt32(br_read(4), 0); | 52 | myHeader.NS = BitConverter.ToUInt32(br_read(4), 0); |
53 | myHeader.CE = BitConverter.ToUInt32(br_read(4), 0); | 53 | myHeader.CE = BitConverter.ToUInt32(br_read(4), 0); |
54 | myHeader.IE = BitConverter.ToUInt32(br_read(4), 0); | 54 | myHeader.IE = BitConverter.ToUInt32(br_read(4), 0); |
55 | myHeader.ER = BitConverter.ToUInt32(br_read(4), 0); | 55 | myHeader.ER = BitConverter.ToUInt32(br_read(4), 0); |
56 | myHeader.FR = BitConverter.ToUInt32(br_read(4), 0); | 56 | myHeader.FR = BitConverter.ToUInt32(br_read(4), 0); |
57 | myHeader.SLR = BitConverter.ToUInt32(br_read(4), 0); | 57 | myHeader.SLR = BitConverter.ToUInt32(br_read(4), 0); |
58 | myHeader.GVR = BitConverter.ToUInt32(br_read(4), 0); | 58 | myHeader.GVR = BitConverter.ToUInt32(br_read(4), 0); |
59 | myHeader.GFR = BitConverter.ToUInt32(br_read(4), 0); | 59 | myHeader.GFR = BitConverter.ToUInt32(br_read(4), 0); |
60 | myHeader.PR = BitConverter.ToUInt32(br_read(4), 0); | 60 | myHeader.PR = BitConverter.ToUInt32(br_read(4), 0); |
61 | myHeader.ESR = BitConverter.ToUInt32(br_read(4), 0); | 61 | myHeader.ESR = BitConverter.ToUInt32(br_read(4), 0); |
62 | myHeader.SR = BitConverter.ToUInt32(br_read(4), 0); | 62 | myHeader.SR = BitConverter.ToUInt32(br_read(4), 0); |
63 | myHeader.NCE = BitConverter.ToUInt64(br_read(8), 0); | 63 | myHeader.NCE = BitConverter.ToUInt64(br_read(8), 0); |
64 | myHeader.NIE = BitConverter.ToUInt64(br_read(8), 0); | 64 | myHeader.NIE = BitConverter.ToUInt64(br_read(8), 0); |
65 | myHeader.NER = BitConverter.ToUInt64(br_read(8), 0); | 65 | myHeader.NER = BitConverter.ToUInt64(br_read(8), 0); |
66 | 66 | ||
67 | // Print Header Block to debug | 67 | // Print Header Block to debug |
68 | SendToDebug("TM - Top of memory (size): " + myHeader.TM); | 68 | SendToDebug("TM - Top of memory (size): " + myHeader.TM); |
69 | SendToDebug("IP - Instruction Pointer (0=not running): " + myHeader.IP); | 69 | SendToDebug("IP - Instruction Pointer (0=not running): " + myHeader.IP); |
70 | SendToDebug("VN - Version number: " + myHeader.VN); | 70 | SendToDebug("VN - Version number: " + myHeader.VN); |
71 | SendToDebug("BP - Local Frame Pointer: " + myHeader.BP); | 71 | SendToDebug("BP - Local Frame Pointer: " + myHeader.BP); |
72 | SendToDebug("SP - Stack Pointer: " + myHeader.SP); | 72 | SendToDebug("SP - Stack Pointer: " + myHeader.SP); |
73 | SendToDebug("HR - Heap Register: " + myHeader.HR); | 73 | SendToDebug("HR - Heap Register: " + myHeader.HR); |
74 | SendToDebug("HP - Heap Pointer: " + myHeader.HP); | 74 | SendToDebug("HP - Heap Pointer: " + myHeader.HP); |
75 | SendToDebug("CS - Current State: " + myHeader.CS); | 75 | SendToDebug("CS - Current State: " + myHeader.CS); |
76 | SendToDebug("NS - Next State: " + myHeader.NS); | 76 | SendToDebug("NS - Next State: " + myHeader.NS); |
77 | SendToDebug("CE - Current Events: " + myHeader.CE); | 77 | SendToDebug("CE - Current Events: " + myHeader.CE); |
78 | SendToDebug("IE - In Event: " + myHeader.IE); | 78 | SendToDebug("IE - In Event: " + myHeader.IE); |
79 | SendToDebug("ER - Event Register: " + myHeader.ER); | 79 | SendToDebug("ER - Event Register: " + myHeader.ER); |
80 | SendToDebug("FR - Fault Register: " + myHeader.FR); | 80 | SendToDebug("FR - Fault Register: " + myHeader.FR); |
81 | SendToDebug("SLR - Sleep Register: " + myHeader.SLR); | 81 | SendToDebug("SLR - Sleep Register: " + myHeader.SLR); |
82 | SendToDebug("GVR - Global Variable Register: " + myHeader.GVR); | 82 | SendToDebug("GVR - Global Variable Register: " + myHeader.GVR); |
83 | SendToDebug("GFR - Global Function Register: " + myHeader.GFR); | 83 | SendToDebug("GFR - Global Function Register: " + myHeader.GFR); |
84 | SendToDebug("PR - Parameter Register: " + myHeader.PR); | 84 | SendToDebug("PR - Parameter Register: " + myHeader.PR); |
85 | SendToDebug("ESR - Energy Supply Register: " + myHeader.ESR); | 85 | SendToDebug("ESR - Energy Supply Register: " + myHeader.ESR); |
86 | SendToDebug("SR - State Register: " + myHeader.SR); | 86 | SendToDebug("SR - State Register: " + myHeader.SR); |
87 | SendToDebug("NCE - 64-bit Current Events: " + myHeader.NCE); | 87 | SendToDebug("NCE - 64-bit Current Events: " + myHeader.NCE); |
88 | SendToDebug("NIE - 64-bit In Events: " + myHeader.NIE); | 88 | SendToDebug("NIE - 64-bit In Events: " + myHeader.NIE); |
89 | SendToDebug("NER - 64-bit Event Register: " + myHeader.NER); | 89 | SendToDebug("NER - 64-bit Event Register: " + myHeader.NER); |
90 | SendToDebug("Read position when exiting HEADER BLOCK: " + fs.Position); | 90 | SendToDebug("Read position when exiting HEADER BLOCK: " + fs.Position); |
91 | 91 | ||
92 | // STATIC BLOCK | 92 | // STATIC BLOCK |
93 | SendToDebug("Reading STATIC BLOCK at: " + myHeader.GVR); | 93 | SendToDebug("Reading STATIC BLOCK at: " + myHeader.GVR); |
94 | fs.Seek(myHeader.GVR, SeekOrigin.Begin); | 94 | fs.Seek(myHeader.GVR, SeekOrigin.Begin); |
95 | int StaticBlockCount = 0; | 95 | int StaticBlockCount = 0; |
96 | // Read function blocks until we hit GFR | 96 | // Read function blocks until we hit GFR |
97 | while (fs.Position < myHeader.GFR) | 97 | while (fs.Position < myHeader.GFR) |
98 | { | 98 | { |
99 | StaticBlockCount++; | 99 | StaticBlockCount++; |
100 | SendToDebug("Reading Static Block " + StaticBlockCount + " at: " + fs.Position); | 100 | SendToDebug("Reading Static Block " + StaticBlockCount + " at: " + fs.Position); |
101 | //fs.Seek(myHeader.GVR, SeekOrigin.Begin); | 101 | //fs.Seek(myHeader.GVR, SeekOrigin.Begin); |
102 | LSO_Struct.StaticBlock myStaticBlock = new LSO_Struct.StaticBlock(); | 102 | LSO_Struct.StaticBlock myStaticBlock = new LSO_Struct.StaticBlock(); |
103 | myStaticBlock.Static_Chunk_Header_Size = BitConverter.ToUInt32(br_read(4), 0); | 103 | myStaticBlock.Static_Chunk_Header_Size = BitConverter.ToUInt32(br_read(4), 0); |
104 | myStaticBlock.ObjectType = br_read(1)[0]; | 104 | myStaticBlock.ObjectType = br_read(1)[0]; |
105 | SendToDebug("Static Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myStaticBlock.ObjectType).ToString()); | 105 | SendToDebug("Static Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myStaticBlock.ObjectType).ToString()); |
106 | myStaticBlock.Unknown = br_read(1)[0]; | 106 | myStaticBlock.Unknown = br_read(1)[0]; |
107 | // Size of datatype varies | 107 | // Size of datatype varies |
108 | if (myStaticBlock.ObjectType != 0) | 108 | if (myStaticBlock.ObjectType != 0) |
109 | myStaticBlock.BlockVariable = br_read(getObjectSize(myStaticBlock.ObjectType)); | 109 | myStaticBlock.BlockVariable = br_read(getObjectSize(myStaticBlock.ObjectType)); |
110 | } | 110 | } |
111 | SendToDebug("Number of Static Blocks read: " + StaticBlockCount); | 111 | SendToDebug("Number of Static Blocks read: " + StaticBlockCount); |
112 | 112 | ||
113 | 113 | ||
114 | // FUNCTION BLOCK | 114 | // FUNCTION BLOCK |
115 | // Always right after STATIC BLOCK | 115 | // Always right after STATIC BLOCK |
116 | LSO_Struct.FunctionBlock myFunctionBlock = new LSO_Struct.FunctionBlock(); | 116 | LSO_Struct.FunctionBlock myFunctionBlock = new LSO_Struct.FunctionBlock(); |
117 | if (myHeader.GFR == myHeader.SR) | 117 | if (myHeader.GFR == myHeader.SR) |
118 | { | 118 | { |
119 | // If GFR and SR are at same position then there is no fuction block | 119 | // If GFR and SR are at same position then there is no fuction block |
120 | SendToDebug("No FUNCTION BLOCK found"); | 120 | SendToDebug("No FUNCTION BLOCK found"); |
121 | } else { | 121 | } else { |
122 | SendToDebug("Reading FUNCTION BLOCK at: " + myHeader.GFR); | 122 | SendToDebug("Reading FUNCTION BLOCK at: " + myHeader.GFR); |
123 | fs.Seek(myHeader.GFR, SeekOrigin.Begin); | 123 | fs.Seek(myHeader.GFR, SeekOrigin.Begin); |
124 | myFunctionBlock.FunctionCount = BitConverter.ToUInt32(br_read(4), 0); | 124 | myFunctionBlock.FunctionCount = BitConverter.ToUInt32(br_read(4), 0); |
125 | SendToDebug("Number of functions in Fuction Block: " + myFunctionBlock.FunctionCount); | 125 | SendToDebug("Number of functions in Fuction Block: " + myFunctionBlock.FunctionCount); |
126 | if (myFunctionBlock.FunctionCount > 0) | 126 | if (myFunctionBlock.FunctionCount > 0) |
127 | { | 127 | { |
128 | myFunctionBlock.CodeChunkPointer = new UInt32[myFunctionBlock.FunctionCount]; | 128 | myFunctionBlock.CodeChunkPointer = new UInt32[myFunctionBlock.FunctionCount]; |
129 | for (int i = 0; i < myFunctionBlock.FunctionCount; i++) | 129 | for (int i = 0; i < myFunctionBlock.FunctionCount; i++) |
130 | { | 130 | { |
131 | SendToDebug("Reading function " + i + " at: " + fs.Position); | 131 | SendToDebug("Reading function " + i + " at: " + fs.Position); |
132 | // TODO: ADD TO FUNCTION LIST (How do we identify it later?) | 132 | // TODO: ADD TO FUNCTION LIST (How do we identify it later?) |
133 | // Note! Absolute position | 133 | // Note! Absolute position |
134 | myFunctionBlock.CodeChunkPointer[i] = BitConverter.ToUInt32(br_read(4), 0) + myHeader.GFR; | 134 | myFunctionBlock.CodeChunkPointer[i] = BitConverter.ToUInt32(br_read(4), 0) + myHeader.GFR; |
135 | SendToDebug("Fuction " + i + " code chunk position: " + myFunctionBlock.CodeChunkPointer[i]); | 135 | SendToDebug("Fuction " + i + " code chunk position: " + myFunctionBlock.CodeChunkPointer[i]); |
136 | } | 136 | } |
137 | } | 137 | } |
138 | } | 138 | } |
139 | 139 | ||
140 | 140 | ||
141 | // STATE FRAME BLOCK | 141 | // STATE FRAME BLOCK |
142 | // Always right after FUNCTION BLOCK | 142 | // Always right after FUNCTION BLOCK |
143 | SendToDebug("Reading STATE BLOCK at: " + myHeader.SR); | 143 | SendToDebug("Reading STATE BLOCK at: " + myHeader.SR); |
144 | fs.Seek(myHeader.SR, SeekOrigin.Begin); | 144 | fs.Seek(myHeader.SR, SeekOrigin.Begin); |
145 | LSO_Struct.StateFrameBlock myStateFrameBlock = new LSO_Struct.StateFrameBlock(); | 145 | LSO_Struct.StateFrameBlock myStateFrameBlock = new LSO_Struct.StateFrameBlock(); |
146 | myStateFrameBlock.StateCount = BitConverter.ToUInt32(br_read(4), 0); | 146 | myStateFrameBlock.StateCount = BitConverter.ToUInt32(br_read(4), 0); |
147 | if (myStateFrameBlock.StateCount > 0) | 147 | if (myStateFrameBlock.StateCount > 0) |
148 | { | 148 | { |
149 | // Initialize array | 149 | // Initialize array |
150 | myStateFrameBlock.StatePointer = new LSO_Struct.StatePointerBlock[myStateFrameBlock.StateCount]; | 150 | myStateFrameBlock.StatePointer = new LSO_Struct.StatePointerBlock[myStateFrameBlock.StateCount]; |
151 | for (int i = 0; i < myStateFrameBlock.StateCount; i++) | 151 | for (int i = 0; i < myStateFrameBlock.StateCount; i++) |
152 | { | 152 | { |
153 | SendToDebug("Reading STATE POINTER BLOCK " + (i+1) + " at: " + fs.Position); | 153 | SendToDebug("Reading STATE POINTER BLOCK " + (i+1) + " at: " + fs.Position); |
154 | // Position is relative to state frame | 154 | // Position is relative to state frame |
155 | myStateFrameBlock.StatePointer[i].Location = myHeader.SR + BitConverter.ToUInt32(br_read(4), 0); | 155 | myStateFrameBlock.StatePointer[i].Location = myHeader.SR + BitConverter.ToUInt32(br_read(4), 0); |
156 | myStateFrameBlock.StatePointer[i].EventMask = new System.Collections.BitArray(br_read(8)); | 156 | myStateFrameBlock.StatePointer[i].EventMask = new System.Collections.BitArray(br_read(8)); |
157 | SendToDebug("Pointer: " + myStateFrameBlock.StatePointer[i].Location); | 157 | SendToDebug("Pointer: " + myStateFrameBlock.StatePointer[i].Location); |
158 | SendToDebug("Total potential EventMask bits: " + myStateFrameBlock.StatePointer[i].EventMask.Count); | 158 | SendToDebug("Total potential EventMask bits: " + myStateFrameBlock.StatePointer[i].EventMask.Count); |
159 | 159 | ||
160 | //// Read STATE BLOCK | 160 | //// Read STATE BLOCK |
161 | //long CurPos = fs.Position; | 161 | //long CurPos = fs.Position; |
162 | //fs.Seek(CurPos, SeekOrigin.Begin); | 162 | //fs.Seek(CurPos, SeekOrigin.Begin); |
163 | 163 | ||
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | 167 | ||
168 | // STATE BLOCK | 168 | // STATE BLOCK |
169 | // For each StateFrameBlock there is one StateBlock with multiple event handlers | 169 | // For each StateFrameBlock there is one StateBlock with multiple event handlers |
170 | 170 | ||
171 | if (myStateFrameBlock.StateCount > 0) | 171 | if (myStateFrameBlock.StateCount > 0) |
172 | { | 172 | { |
173 | // Go through all State Frame Pointers found | 173 | // Go through all State Frame Pointers found |
174 | for (int i = 0; i < myStateFrameBlock.StateCount; i++) | 174 | for (int i = 0; i < myStateFrameBlock.StateCount; i++) |
175 | { | 175 | { |
176 | 176 | ||
177 | fs.Seek(myStateFrameBlock.StatePointer[i].Location, SeekOrigin.Begin); | 177 | fs.Seek(myStateFrameBlock.StatePointer[i].Location, SeekOrigin.Begin); |
178 | SendToDebug("Reading STATE BLOCK " + (i + 1) + " at: " + fs.Position); | 178 | SendToDebug("Reading STATE BLOCK " + (i + 1) + " at: " + fs.Position); |
179 | 179 | ||
180 | // READ: STATE BLOCK HEADER | 180 | // READ: STATE BLOCK HEADER |
181 | myStateFrameBlock.StatePointer[i].StateBlock = new LSO_Struct.StateBlock(); | 181 | myStateFrameBlock.StatePointer[i].StateBlock = new LSO_Struct.StateBlock(); |
182 | myStateFrameBlock.StatePointer[i].StateBlock.StartPos = (UInt32)fs.Position; // Note | 182 | myStateFrameBlock.StatePointer[i].StateBlock.StartPos = (UInt32)fs.Position; // Note |
183 | myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize = BitConverter.ToUInt32(br_read(4), 0); | 183 | myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize = BitConverter.ToUInt32(br_read(4), 0); |
184 | myStateFrameBlock.StatePointer[i].StateBlock.Unknown = br_read(1)[0]; | 184 | myStateFrameBlock.StatePointer[i].StateBlock.Unknown = br_read(1)[0]; |
185 | myStateFrameBlock.StatePointer[i].StateBlock.EndPos = (UInt32)fs.Position; // Note | 185 | myStateFrameBlock.StatePointer[i].StateBlock.EndPos = (UInt32)fs.Position; // Note |
186 | SendToDebug("State block Start Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.StartPos); | 186 | SendToDebug("State block Start Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.StartPos); |
187 | SendToDebug("State block Header Size: " + myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize); | 187 | SendToDebug("State block Header Size: " + myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize); |
188 | SendToDebug("State block Header End Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.EndPos); | 188 | SendToDebug("State block Header End Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.EndPos); |
189 | 189 | ||
190 | // We need to count number of bits flagged in EventMask? | 190 | // We need to count number of bits flagged in EventMask? |
191 | 191 | ||
192 | 192 | ||
193 | // for each bit in myStateFrameBlock.StatePointer[i].EventMask | 193 | // for each bit in myStateFrameBlock.StatePointer[i].EventMask |
194 | 194 | ||
195 | // ADDING TO ALL RIGHT NOW, SHOULD LIMIT TO ONLY THE ONES IN USE | 195 | // ADDING TO ALL RIGHT NOW, SHOULD LIMIT TO ONLY THE ONES IN USE |
196 | //TODO: Create event hooks | 196 | //TODO: Create event hooks |
197 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers = new LSO_Struct.StateBlockHandler[myStateFrameBlock.StatePointer[i].EventMask.Count - 1]; | 197 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers = new LSO_Struct.StateBlockHandler[myStateFrameBlock.StatePointer[i].EventMask.Count - 1]; |
198 | for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++) | 198 | for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++) |
199 | { | 199 | { |
200 | 200 | ||
201 | if (myStateFrameBlock.StatePointer[i].EventMask.Get(ii) == true) | 201 | if (myStateFrameBlock.StatePointer[i].EventMask.Get(ii) == true) |
202 | { | 202 | { |
203 | // We got an event | 203 | // We got an event |
204 | // READ: STATE BLOCK HANDLER | 204 | // READ: STATE BLOCK HANDLER |
205 | SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER matching EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") at: " + fs.Position); | 205 | SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER matching EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") at: " + fs.Position); |
206 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer = myStateFrameBlock.StatePointer[i].StateBlock.EndPos + BitConverter.ToUInt32(br_read(4), 0); | 206 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer = myStateFrameBlock.StatePointer[i].StateBlock.EndPos + BitConverter.ToUInt32(br_read(4), 0); |
207 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize = BitConverter.ToUInt32(br_read(4), 0); | 207 | myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize = BitConverter.ToUInt32(br_read(4), 0); |
208 | SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Code Chunk Pointer: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer); | 208 | SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Code Chunk Pointer: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer); |
209 | SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Call Frame Size: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize ); | 209 | SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Call Frame Size: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize ); |
210 | } | 210 | } |
211 | } | 211 | } |
212 | } | 212 | } |
213 | } | 213 | } |
214 | 214 | ||
215 | 215 | ||
216 | 216 | ||
217 | 217 | ||
218 | //// READ FUNCTION CODE CHUNKS | 218 | //// READ FUNCTION CODE CHUNKS |
219 | //// Functions + Function start pos (GFR) | 219 | //// Functions + Function start pos (GFR) |
220 | //// TODO: Somehow be able to identify and reference this | 220 | //// TODO: Somehow be able to identify and reference this |
221 | //LSO_Struct.CodeChunk[] myFunctionCodeChunk; | 221 | //LSO_Struct.CodeChunk[] myFunctionCodeChunk; |
222 | //if (myFunctionBlock.FunctionCount > 0) | 222 | //if (myFunctionBlock.FunctionCount > 0) |
223 | //{ | 223 | //{ |
224 | // myFunctionCodeChunk = new LSO_Struct.CodeChunk[myFunctionBlock.FunctionCount]; | 224 | // myFunctionCodeChunk = new LSO_Struct.CodeChunk[myFunctionBlock.FunctionCount]; |
225 | // for (int i = 0; i < myFunctionBlock.FunctionCount; i++) | 225 | // for (int i = 0; i < myFunctionBlock.FunctionCount; i++) |
226 | // { | 226 | // { |
227 | // SendToDebug("Reading Function Code Chunk " + i); | 227 | // SendToDebug("Reading Function Code Chunk " + i); |
228 | // myFunctionCodeChunk[i] = GetCodeChunk((UInt32)myFunctionBlock.CodeChunkPointer[i]); | 228 | // myFunctionCodeChunk[i] = GetCodeChunk((UInt32)myFunctionBlock.CodeChunkPointer[i]); |
229 | // } | 229 | // } |
230 | 230 | ||
231 | //} | 231 | //} |
232 | // READ EVENT CODE CHUNKS | 232 | // READ EVENT CODE CHUNKS |
233 | LSO_Struct.CodeChunk[] myEventCodeChunk; | 233 | LSO_Struct.CodeChunk[] myEventCodeChunk; |
234 | if (myStateFrameBlock.StateCount > 0) | 234 | if (myStateFrameBlock.StateCount > 0) |
235 | { | 235 | { |
236 | myEventCodeChunk = new LSO_Struct.CodeChunk[myStateFrameBlock.StateCount]; | 236 | myEventCodeChunk = new LSO_Struct.CodeChunk[myStateFrameBlock.StateCount]; |
237 | for (int i = 0; i < myStateFrameBlock.StateCount; i++) | 237 | for (int i = 0; i < myStateFrameBlock.StateCount; i++) |
238 | { | 238 | { |
239 | // TODO: Somehow organize events and functions so they can be found again, | 239 | // TODO: Somehow organize events and functions so they can be found again, |
240 | // two level search ain't no good | 240 | // two level search ain't no good |
241 | for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++) | 241 | for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++) |
242 | { | 242 | { |
243 | 243 | ||
244 | 244 | ||
245 | if (myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer > 0) | 245 | if (myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer > 0) |
246 | { | 246 | { |
247 | SendToDebug("Reading Event Code Chunk state " + i + ", event " + (LSO_Enums.Event_Mask_Values)ii); | 247 | SendToDebug("Reading Event Code Chunk state " + i + ", event " + (LSO_Enums.Event_Mask_Values)ii); |
248 | 248 | ||
249 | 249 | ||
250 | // Override a Method / Function | 250 | // Override a Method / Function |
251 | string eventname = "event_" + (LSO_Enums.Event_Mask_Values)ii; | 251 | string eventname = "event_" + (LSO_Enums.Event_Mask_Values)ii; |
252 | SendToDebug("CLR:" + eventname + ":MethodBuilder methodBuilder = typeBuilder.DefineMethod..."); | 252 | SendToDebug("CLR:" + eventname + ":MethodBuilder methodBuilder = typeBuilder.DefineMethod..."); |
253 | MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname, | 253 | MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname, |
254 | MethodAttributes.Private | MethodAttributes.Virtual, | 254 | MethodAttributes.Private | MethodAttributes.Virtual, |
255 | typeof(void), | 255 | typeof(void), |
256 | new Type[] { typeof(object) }); | 256 | new Type[] { typeof(object) }); |
257 | 257 | ||
258 | SendToDebug("CLR:" + eventname + ":typeBuilder.DefineMethodOverride(methodBuilder..."); | 258 | SendToDebug("CLR:" + eventname + ":typeBuilder.DefineMethodOverride(methodBuilder..."); |
259 | typeBuilder.DefineMethodOverride(methodBuilder, | 259 | typeBuilder.DefineMethodOverride(methodBuilder, |
260 | typeof(LSL_CLRInterface.LSLScript).GetMethod(eventname)); | 260 | typeof(LSL_CLRInterface.LSLScript).GetMethod(eventname)); |
261 | 261 | ||
262 | // Create the IL generator | 262 | // Create the IL generator |
263 | 263 | ||
264 | SendToDebug("CLR:" + eventname + ":ILGenerator il = methodBuilder.GetILGenerator();"); | 264 | SendToDebug("CLR:" + eventname + ":ILGenerator il = methodBuilder.GetILGenerator();"); |
265 | ILGenerator il = methodBuilder.GetILGenerator(); | 265 | ILGenerator il = methodBuilder.GetILGenerator(); |
266 | 266 | ||
267 | 267 | ||
268 | LSO_Struct.CodeChunk myECC = | 268 | LSO_Struct.CodeChunk myECC = |
269 | GetCodeChunk(myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer, il, eventname); | 269 | GetCodeChunk(myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer, il, eventname); |
270 | } | 270 | } |
271 | 271 | ||
272 | } | 272 | } |
273 | } | 273 | } |
274 | 274 | ||
275 | } | 275 | } |
276 | 276 | ||
277 | 277 | ||
278 | // Close | 278 | // Close |
279 | br.Close(); | 279 | br.Close(); |
280 | fs.Close(); | 280 | fs.Close(); |
281 | 281 | ||
282 | } | 282 | } |
283 | 283 | ||
284 | private LSO_Struct.HeapBlock GetHeap(UInt32 pos) | 284 | private LSO_Struct.HeapBlock GetHeap(UInt32 pos) |
285 | { | 285 | { |
286 | // HEAP BLOCK | 286 | // HEAP BLOCK |
287 | // TODO:? Special read for strings/keys (null terminated) and lists (pointers to other HEAP entries) | 287 | // TODO:? Special read for strings/keys (null terminated) and lists (pointers to other HEAP entries) |
288 | SendToDebug("Reading HEAP BLOCK at: " + pos); | 288 | SendToDebug("Reading HEAP BLOCK at: " + pos); |
289 | fs.Seek(pos, SeekOrigin.Begin); | 289 | fs.Seek(pos, SeekOrigin.Begin); |
290 | 290 | ||
291 | LSO_Struct.HeapBlock myHeapBlock = new LSO_Struct.HeapBlock(); | 291 | LSO_Struct.HeapBlock myHeapBlock = new LSO_Struct.HeapBlock(); |
292 | myHeapBlock.DataBlockSize = BitConverter.ToUInt32(br_read(4), 0); | 292 | myHeapBlock.DataBlockSize = BitConverter.ToUInt32(br_read(4), 0); |
293 | myHeapBlock.ObjectType = br_read(1)[0]; | 293 | myHeapBlock.ObjectType = br_read(1)[0]; |
294 | myHeapBlock.ReferenceCount = BitConverter.ToUInt16(br_read(2), 0); | 294 | myHeapBlock.ReferenceCount = BitConverter.ToUInt16(br_read(2), 0); |
295 | myHeapBlock.Data = br_read(getObjectSize(myHeapBlock.ObjectType)); | 295 | myHeapBlock.Data = br_read(getObjectSize(myHeapBlock.ObjectType)); |
296 | 296 | ||
297 | SendToDebug("Heap Block Data Block Size: " + myHeapBlock.DataBlockSize); | 297 | SendToDebug("Heap Block Data Block Size: " + myHeapBlock.DataBlockSize); |
298 | SendToDebug("Heap Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myHeapBlock.ObjectType).ToString()); | 298 | SendToDebug("Heap Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myHeapBlock.ObjectType).ToString()); |
299 | SendToDebug("Heap Block Reference Count: " + myHeapBlock.ReferenceCount); | 299 | SendToDebug("Heap Block Reference Count: " + myHeapBlock.ReferenceCount); |
300 | 300 | ||
301 | return myHeapBlock; | 301 | return myHeapBlock; |
302 | } | 302 | } |
303 | 303 | ||
304 | 304 | ||
305 | 305 | ||
306 | private byte[] br_read(int len) | 306 | private byte[] br_read(int len) |
307 | { | 307 | { |
308 | if (len <= 0) | 308 | if (len <= 0) |
309 | return null; | 309 | return null; |
310 | 310 | ||
311 | try | 311 | try |
312 | { | 312 | { |
313 | byte[] bytes = new byte[len]; | 313 | byte[] bytes = new byte[len]; |
314 | for (int i = len - 1; i > -1; i--) | 314 | for (int i = len - 1; i > -1; i--) |
315 | bytes[i] = br.ReadByte(); | 315 | bytes[i] = br.ReadByte(); |
316 | return bytes; | 316 | return bytes; |
317 | } | 317 | } |
318 | catch (Exception e) | 318 | catch (Exception e) |
319 | { | 319 | { |
320 | SendToDebug("Exception: " + e.ToString()); | 320 | SendToDebug("Exception: " + e.ToString()); |
321 | throw (e); | 321 | throw (e); |
322 | } | 322 | } |
323 | } | 323 | } |
324 | //private byte[] br_read_smallendian(int len) | 324 | //private byte[] br_read_smallendian(int len) |
325 | //{ | 325 | //{ |
326 | // byte[] bytes = new byte[len]; | 326 | // byte[] bytes = new byte[len]; |
327 | // br.Read(bytes,0, len); | 327 | // br.Read(bytes,0, len); |
328 | // return bytes; | 328 | // return bytes; |
329 | //} | 329 | //} |
330 | 330 | ||
331 | private int getObjectSize(byte ObjectType) | 331 | private int getObjectSize(byte ObjectType) |
332 | { | 332 | { |
333 | switch (ObjectType) | 333 | switch (ObjectType) |
334 | { | 334 | { |
335 | case 1: | 335 | case 1: |
336 | case 2: | 336 | case 2: |
337 | case 3: | 337 | case 3: |
338 | case 4: | 338 | case 4: |
339 | case 7: | 339 | case 7: |
340 | return 4; | 340 | return 4; |
341 | case 5: | 341 | case 5: |
342 | return 12; | 342 | return 12; |
343 | case 6: | 343 | case 6: |
344 | return 16; | 344 | return 16; |
345 | default: | 345 | default: |
346 | return 0; | 346 | return 0; |
347 | } | 347 | } |
348 | } | 348 | } |
349 | private void SendToDebug(string Message) | 349 | private void SendToDebug(string Message) |
350 | { | 350 | { |
351 | if (Debug == true) | 351 | if (Debug == true) |
352 | Console.WriteLine("Debug: " + Message); | 352 | Console.WriteLine("Debug: " + Message); |
353 | } | 353 | } |
354 | 354 | ||
355 | 355 | ||
356 | private string Read_String() | 356 | private string Read_String() |
357 | { | 357 | { |
358 | string ret = ""; | 358 | string ret = ""; |
359 | byte reader = br_read(1)[0]; | 359 | byte reader = br_read(1)[0]; |
360 | while (reader != 0x000) | 360 | while (reader != 0x000) |
361 | { | 361 | { |
362 | ret += (char)reader; | 362 | ret += (char)reader; |
363 | reader = br_read(1)[0]; | 363 | reader = br_read(1)[0]; |
364 | } | 364 | } |
365 | return ret; | 365 | return ret; |
366 | } | 366 | } |
367 | 367 | ||
368 | /// <summary> | 368 | /// <summary> |
369 | /// Reads a code chunk into structure and returns it. | 369 | /// Reads a code chunk into structure and returns it. |
370 | /// </summary> | 370 | /// </summary> |
371 | /// <param name="pos">Absolute position in file. REMEMBER TO ADD myHeader.GFR!</param> | 371 | /// <param name="pos">Absolute position in file. REMEMBER TO ADD myHeader.GFR!</param> |
372 | /// <returns></returns> | 372 | /// <returns></returns> |
373 | private LSO_Struct.CodeChunk GetCodeChunk(UInt32 pos, ILGenerator il, string eventname) | 373 | private LSO_Struct.CodeChunk GetCodeChunk(UInt32 pos, ILGenerator il, string eventname) |
374 | { | 374 | { |
375 | 375 | ||
376 | /* | 376 | /* |
377 | * CLR TRY | 377 | * CLR TRY |
378 | */ | 378 | */ |
379 | //SendToDebug("CLR:" + eventname + ":il.BeginExceptionBlock()"); | 379 | //SendToDebug("CLR:" + eventname + ":il.BeginExceptionBlock()"); |
380 | il.BeginExceptionBlock(); | 380 | il.BeginExceptionBlock(); |
381 | 381 | ||
382 | // Push "Hello World!" string to stack | 382 | // Push "Hello World!" string to stack |
383 | //SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr..."); | 383 | //SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr..."); |
384 | il.Emit(OpCodes.Ldstr, "Starting CLR dynamic execution of: " + eventname); | 384 | il.Emit(OpCodes.Ldstr, "Starting CLR dynamic execution of: " + eventname); |
385 | 385 | ||
386 | // Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!"); | 386 | // Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!"); |
387 | //SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); | 387 | //SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); |
388 | il.Emit(OpCodes.Call, typeof(Console).GetMethod | 388 | il.Emit(OpCodes.Call, typeof(Console).GetMethod |
389 | ("WriteLine", new Type[] { typeof(string) })); | 389 | ("WriteLine", new Type[] { typeof(string) })); |
390 | 390 | ||
391 | 391 | ||
392 | LSO_Struct.CodeChunk myCodeChunk = new LSO_Struct.CodeChunk(); | 392 | LSO_Struct.CodeChunk myCodeChunk = new LSO_Struct.CodeChunk(); |
393 | 393 | ||
394 | SendToDebug("Reading Function Code Chunk at: " + pos); | 394 | SendToDebug("Reading Function Code Chunk at: " + pos); |
395 | fs.Seek(pos, SeekOrigin.Begin); | 395 | fs.Seek(pos, SeekOrigin.Begin); |
396 | myCodeChunk.CodeChunkHeaderSize = BitConverter.ToUInt32(br_read(4), 0); | 396 | myCodeChunk.CodeChunkHeaderSize = BitConverter.ToUInt32(br_read(4), 0); |
397 | SendToDebug("CodeChunk Header Size: " + myCodeChunk.CodeChunkHeaderSize ); | 397 | SendToDebug("CodeChunk Header Size: " + myCodeChunk.CodeChunkHeaderSize ); |
398 | // Read until null | 398 | // Read until null |
399 | myCodeChunk.Comment = Read_String(); | 399 | myCodeChunk.Comment = Read_String(); |
400 | SendToDebug("Function comment: " + myCodeChunk.Comment); | 400 | SendToDebug("Function comment: " + myCodeChunk.Comment); |
401 | myCodeChunk.ReturnType = br_read(1)[0]; | 401 | myCodeChunk.ReturnType = br_read(1)[0]; |
402 | SendToDebug("Return type: " + (LSO_Enums.Variable_Type_Codes)myCodeChunk.ReturnType); | 402 | SendToDebug("Return type: " + (LSO_Enums.Variable_Type_Codes)myCodeChunk.ReturnType); |
403 | // TODO: How to determine number of codechunks -- does this method work? | 403 | // TODO: How to determine number of codechunks -- does this method work? |
404 | myCodeChunk.CodeChunkArguments = new System.Collections.Generic.List<LSO_Struct.CodeChunkArgument>(); | 404 | myCodeChunk.CodeChunkArguments = new System.Collections.Generic.List<LSO_Struct.CodeChunkArgument>(); |
405 | byte reader = br_read(1)[0]; | 405 | byte reader = br_read(1)[0]; |
406 | reader = br_read(1)[0]; | 406 | reader = br_read(1)[0]; |
407 | int ccount = 0; | 407 | int ccount = 0; |
408 | while (reader != 0x000) | 408 | while (reader != 0x000) |
409 | { | 409 | { |
410 | ccount++; | 410 | ccount++; |
411 | SendToDebug("Reading Code Chunk Argument " + ccount); | 411 | SendToDebug("Reading Code Chunk Argument " + ccount); |
412 | LSO_Struct.CodeChunkArgument CCA = new LSO_Struct.CodeChunkArgument(); | 412 | LSO_Struct.CodeChunkArgument CCA = new LSO_Struct.CodeChunkArgument(); |
413 | CCA.FunctionReturnType = reader; | 413 | CCA.FunctionReturnType = reader; |
414 | reader = br_read(1)[0]; | 414 | reader = br_read(1)[0]; |
415 | CCA.NullString = reader; | 415 | CCA.NullString = reader; |
416 | myCodeChunk.CodeChunkArguments.Add(CCA); | 416 | myCodeChunk.CodeChunkArguments.Add(CCA); |
417 | SendToDebug("Code Chunk Argument " + ccount + " return type: " + (LSO_Enums.Variable_Type_Codes)CCA.FunctionReturnType); | 417 | SendToDebug("Code Chunk Argument " + ccount + " return type: " + (LSO_Enums.Variable_Type_Codes)CCA.FunctionReturnType); |
418 | } | 418 | } |
419 | // End marker is 0x000 | 419 | // End marker is 0x000 |
420 | myCodeChunk.EndMarker = reader; | 420 | myCodeChunk.EndMarker = reader; |
421 | // TODO: How to read and identify following code | 421 | // TODO: How to read and identify following code |
422 | // TODO: Code is read until a return of some sort is found | 422 | // TODO: Code is read until a return of some sort is found |
423 | bool FoundRet = false; | 423 | bool FoundRet = false; |
424 | while (FoundRet == false) | 424 | while (FoundRet == false) |
425 | { | 425 | { |
426 | //reader = br_read(1)[0]; | 426 | //reader = br_read(1)[0]; |
427 | //UInt16 opcode = BitConverter.ToUInt16(br_read(1),0); | 427 | //UInt16 opcode = BitConverter.ToUInt16(br_read(1),0); |
428 | UInt16 opcode = br_read(1)[0]; | 428 | UInt16 opcode = br_read(1)[0]; |
429 | //long rPos = fs.Position; | 429 | //long rPos = fs.Position; |
430 | SendToDebug("OPCODE: " + ((LSO_Enums.Operation_Table)opcode).ToString()); | 430 | SendToDebug("OPCODE: " + ((LSO_Enums.Operation_Table)opcode).ToString()); |
431 | switch (opcode) | 431 | switch (opcode) |
432 | { | 432 | { |
433 | // LONG | 433 | // LONG |
434 | case (UInt16)LSO_Enums.Operation_Table.POPARG: | 434 | case (UInt16)LSO_Enums.Operation_Table.POPARG: |
435 | case (UInt16)LSO_Enums.Operation_Table.STORE: | 435 | case (UInt16)LSO_Enums.Operation_Table.STORE: |
436 | case (UInt16)LSO_Enums.Operation_Table.STORES: | 436 | case (UInt16)LSO_Enums.Operation_Table.STORES: |
437 | case (UInt16)LSO_Enums.Operation_Table.STOREL: | 437 | case (UInt16)LSO_Enums.Operation_Table.STOREL: |
438 | case (UInt16)LSO_Enums.Operation_Table.STOREV: | 438 | case (UInt16)LSO_Enums.Operation_Table.STOREV: |
439 | case (UInt16)LSO_Enums.Operation_Table.STOREQ: | 439 | case (UInt16)LSO_Enums.Operation_Table.STOREQ: |
440 | case (UInt16)LSO_Enums.Operation_Table.STOREG: | 440 | case (UInt16)LSO_Enums.Operation_Table.STOREG: |
441 | case (UInt16)LSO_Enums.Operation_Table.STOREGS: | 441 | case (UInt16)LSO_Enums.Operation_Table.STOREGS: |
442 | case (UInt16)LSO_Enums.Operation_Table.STOREGL: | 442 | case (UInt16)LSO_Enums.Operation_Table.STOREGL: |
443 | case (UInt16)LSO_Enums.Operation_Table.STOREGV: | 443 | case (UInt16)LSO_Enums.Operation_Table.STOREGV: |
444 | case (UInt16)LSO_Enums.Operation_Table.STOREGQ: | 444 | case (UInt16)LSO_Enums.Operation_Table.STOREGQ: |
445 | case (UInt16)LSO_Enums.Operation_Table.LOADP: | 445 | case (UInt16)LSO_Enums.Operation_Table.LOADP: |
446 | case (UInt16)LSO_Enums.Operation_Table.LOADSP: | 446 | case (UInt16)LSO_Enums.Operation_Table.LOADSP: |
447 | case (UInt16)LSO_Enums.Operation_Table.LOADLP: | 447 | case (UInt16)LSO_Enums.Operation_Table.LOADLP: |
448 | case (UInt16)LSO_Enums.Operation_Table.LOADVP: | 448 | case (UInt16)LSO_Enums.Operation_Table.LOADVP: |
449 | case (UInt16)LSO_Enums.Operation_Table.LOADQP: | 449 | case (UInt16)LSO_Enums.Operation_Table.LOADQP: |
450 | case (UInt16)LSO_Enums.Operation_Table.PUSH: | 450 | case (UInt16)LSO_Enums.Operation_Table.PUSH: |
451 | case (UInt16)LSO_Enums.Operation_Table.PUSHS: | 451 | case (UInt16)LSO_Enums.Operation_Table.PUSHS: |
452 | case (UInt16)LSO_Enums.Operation_Table.PUSHL: | 452 | case (UInt16)LSO_Enums.Operation_Table.PUSHL: |
453 | case (UInt16)LSO_Enums.Operation_Table.PUSHV: | 453 | case (UInt16)LSO_Enums.Operation_Table.PUSHV: |
454 | case (UInt16)LSO_Enums.Operation_Table.PUSHQ: | 454 | case (UInt16)LSO_Enums.Operation_Table.PUSHQ: |
455 | case (UInt16)LSO_Enums.Operation_Table.PUSHG: | 455 | case (UInt16)LSO_Enums.Operation_Table.PUSHG: |
456 | case (UInt16)LSO_Enums.Operation_Table.PUSHGS: | 456 | case (UInt16)LSO_Enums.Operation_Table.PUSHGS: |
457 | case (UInt16)LSO_Enums.Operation_Table.PUSHGL: | 457 | case (UInt16)LSO_Enums.Operation_Table.PUSHGL: |
458 | case (UInt16)LSO_Enums.Operation_Table.PUSHGV: | 458 | case (UInt16)LSO_Enums.Operation_Table.PUSHGV: |
459 | case (UInt16)LSO_Enums.Operation_Table.PUSHGQ: | 459 | case (UInt16)LSO_Enums.Operation_Table.PUSHGQ: |
460 | SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0)); | 460 | SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0)); |
461 | break; | 461 | break; |
462 | // BYTE | 462 | // BYTE |
463 | case (UInt16)LSO_Enums.Operation_Table.PUSHARGB: | 463 | case (UInt16)LSO_Enums.Operation_Table.PUSHARGB: |
464 | SendToDebug("Param1: " + br_read(1)[0]); | 464 | SendToDebug("Param1: " + br_read(1)[0]); |
465 | break; | 465 | break; |
466 | // INTEGER | 466 | // INTEGER |
467 | case (UInt16)LSO_Enums.Operation_Table.PUSHARGI: | 467 | case (UInt16)LSO_Enums.Operation_Table.PUSHARGI: |
468 | // TODO: What is size of integer? | 468 | // TODO: What is size of integer? |
469 | SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0)); | 469 | SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0)); |
470 | break; | 470 | break; |
471 | // FLOAT | 471 | // FLOAT |
472 | case (UInt16)LSO_Enums.Operation_Table.PUSHARGF: | 472 | case (UInt16)LSO_Enums.Operation_Table.PUSHARGF: |
473 | // TODO: What is size of float? | 473 | // TODO: What is size of float? |
474 | SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0)); | 474 | SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0)); |
475 | break; | 475 | break; |
476 | // STRING | 476 | // STRING |
477 | case (UInt16)LSO_Enums.Operation_Table.PUSHARGS: | 477 | case (UInt16)LSO_Enums.Operation_Table.PUSHARGS: |
478 | string s = Read_String(); | 478 | string s = Read_String(); |
479 | SendToDebug("Param1: " + s); | 479 | SendToDebug("Param1: " + s); |
480 | il.Emit(OpCodes.Ldstr, s); | 480 | il.Emit(OpCodes.Ldstr, s); |
481 | break; | 481 | break; |
482 | // VECTOR z,y,x | 482 | // VECTOR z,y,x |
483 | case (UInt16)LSO_Enums.Operation_Table.PUSHARGV: | 483 | case (UInt16)LSO_Enums.Operation_Table.PUSHARGV: |
484 | SendToDebug("Param1 Z: " + BitConverter.ToUInt32(br_read(4),0)); | 484 | SendToDebug("Param1 Z: " + BitConverter.ToUInt32(br_read(4),0)); |
485 | SendToDebug("Param1 Y: " + BitConverter.ToUInt32(br_read(4),0)); | 485 | SendToDebug("Param1 Y: " + BitConverter.ToUInt32(br_read(4),0)); |
486 | SendToDebug("Param1 X: " + BitConverter.ToUInt32(br_read(4),0)); | 486 | SendToDebug("Param1 X: " + BitConverter.ToUInt32(br_read(4),0)); |
487 | break; | 487 | break; |
488 | // ROTATION s,z,y,x | 488 | // ROTATION s,z,y,x |
489 | case (UInt16)LSO_Enums.Operation_Table.PUSHARGQ: | 489 | case (UInt16)LSO_Enums.Operation_Table.PUSHARGQ: |
490 | SendToDebug("Param1 S: " + BitConverter.ToUInt32(br_read(4),0)); | 490 | SendToDebug("Param1 S: " + BitConverter.ToUInt32(br_read(4),0)); |
491 | SendToDebug("Param1 Z: " + BitConverter.ToUInt32(br_read(4),0)); | 491 | SendToDebug("Param1 Z: " + BitConverter.ToUInt32(br_read(4),0)); |
492 | SendToDebug("Param1 Y: " + BitConverter.ToUInt32(br_read(4),0)); | 492 | SendToDebug("Param1 Y: " + BitConverter.ToUInt32(br_read(4),0)); |
493 | SendToDebug("Param1 X: " + BitConverter.ToUInt32(br_read(4),0)); | 493 | SendToDebug("Param1 X: " + BitConverter.ToUInt32(br_read(4),0)); |
494 | break; | 494 | break; |
495 | // LONG | 495 | // LONG |
496 | case (UInt16)LSO_Enums.Operation_Table.PUSHARGE: | 496 | case (UInt16)LSO_Enums.Operation_Table.PUSHARGE: |
497 | SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0)); | 497 | SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0)); |
498 | break; | 498 | break; |
499 | // BYTE | 499 | // BYTE |
500 | case (UInt16)LSO_Enums.Operation_Table.ADD: | 500 | case (UInt16)LSO_Enums.Operation_Table.ADD: |
501 | case (UInt16)LSO_Enums.Operation_Table.SUB: | 501 | case (UInt16)LSO_Enums.Operation_Table.SUB: |
502 | case (UInt16)LSO_Enums.Operation_Table.MUL: | 502 | case (UInt16)LSO_Enums.Operation_Table.MUL: |
503 | case (UInt16)LSO_Enums.Operation_Table.DIV: | 503 | case (UInt16)LSO_Enums.Operation_Table.DIV: |
504 | case (UInt16)LSO_Enums.Operation_Table.MOD: | 504 | case (UInt16)LSO_Enums.Operation_Table.MOD: |
505 | case (UInt16)LSO_Enums.Operation_Table.EQ: | 505 | case (UInt16)LSO_Enums.Operation_Table.EQ: |
506 | case (UInt16)LSO_Enums.Operation_Table.NEQ: | 506 | case (UInt16)LSO_Enums.Operation_Table.NEQ: |
507 | case (UInt16)LSO_Enums.Operation_Table.LEQ: | 507 | case (UInt16)LSO_Enums.Operation_Table.LEQ: |
508 | case (UInt16)LSO_Enums.Operation_Table.GEQ: | 508 | case (UInt16)LSO_Enums.Operation_Table.GEQ: |
509 | case (UInt16)LSO_Enums.Operation_Table.LESS: | 509 | case (UInt16)LSO_Enums.Operation_Table.LESS: |
510 | case (UInt16)LSO_Enums.Operation_Table.GREATER: | 510 | case (UInt16)LSO_Enums.Operation_Table.GREATER: |
511 | case (UInt16)LSO_Enums.Operation_Table.BOOLOR: | 511 | case (UInt16)LSO_Enums.Operation_Table.BOOLOR: |
512 | SendToDebug("Param1: " + br_read(1)[0]); | 512 | SendToDebug("Param1: " + br_read(1)[0]); |
513 | break; | 513 | break; |
514 | // LONG | 514 | // LONG |
515 | case (UInt16)LSO_Enums.Operation_Table.JUMP: | 515 | case (UInt16)LSO_Enums.Operation_Table.JUMP: |
516 | SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0)); | 516 | SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0)); |
517 | break; | 517 | break; |
518 | // BYTE, LONG | 518 | // BYTE, LONG |
519 | case (UInt16)LSO_Enums.Operation_Table.JUMPIF: | 519 | case (UInt16)LSO_Enums.Operation_Table.JUMPIF: |
520 | case (UInt16)LSO_Enums.Operation_Table.JUMPNIF: | 520 | case (UInt16)LSO_Enums.Operation_Table.JUMPNIF: |
521 | SendToDebug("Param1: " + br_read(1)[0]); | 521 | SendToDebug("Param1: " + br_read(1)[0]); |
522 | SendToDebug("Param2: " + BitConverter.ToUInt32(br_read(4),0)); | 522 | SendToDebug("Param2: " + BitConverter.ToUInt32(br_read(4),0)); |
523 | break; | 523 | break; |
524 | // LONG | 524 | // LONG |
525 | case (UInt16)LSO_Enums.Operation_Table.STATE: | 525 | case (UInt16)LSO_Enums.Operation_Table.STATE: |
526 | case (UInt16)LSO_Enums.Operation_Table.CALL: | 526 | case (UInt16)LSO_Enums.Operation_Table.CALL: |
527 | SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0)); | 527 | SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0)); |
528 | break; | 528 | break; |
529 | // BYTE | 529 | // BYTE |
530 | case (UInt16)LSO_Enums.Operation_Table.CAST: | 530 | case (UInt16)LSO_Enums.Operation_Table.CAST: |
531 | SendToDebug("Param1: " + br_read(1)[0]); | 531 | SendToDebug("Param1: " + br_read(1)[0]); |
532 | break; | 532 | break; |
533 | // LONG | 533 | // LONG |
534 | case (UInt16)LSO_Enums.Operation_Table.STACKTOS: | 534 | case (UInt16)LSO_Enums.Operation_Table.STACKTOS: |
535 | case (UInt16)LSO_Enums.Operation_Table.STACKTOL: | 535 | case (UInt16)LSO_Enums.Operation_Table.STACKTOL: |
536 | SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0)); | 536 | SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0)); |
537 | break; | 537 | break; |
538 | // BYTE | 538 | // BYTE |
539 | case (UInt16)LSO_Enums.Operation_Table.PRINT: | 539 | case (UInt16)LSO_Enums.Operation_Table.PRINT: |
540 | case (UInt16)LSO_Enums.Operation_Table.CALLLIB: | 540 | case (UInt16)LSO_Enums.Operation_Table.CALLLIB: |
541 | SendToDebug("Param1: " + br_read(1)[0]); | 541 | SendToDebug("Param1: " + br_read(1)[0]); |
542 | break; | 542 | break; |
543 | // SHORT | 543 | // SHORT |
544 | case (UInt16)LSO_Enums.Operation_Table.CALLLIB_TWO_BYTE: | 544 | case (UInt16)LSO_Enums.Operation_Table.CALLLIB_TWO_BYTE: |
545 | // TODO: What is size of short? | 545 | // TODO: What is size of short? |
546 | UInt16 _i = BitConverter.ToUInt16(br_read(2), 0); | 546 | UInt16 _i = BitConverter.ToUInt16(br_read(2), 0); |
547 | SendToDebug("Param1: " + _i); | 547 | SendToDebug("Param1: " + _i); |
548 | switch (_i) | 548 | switch (_i) |
549 | { | 549 | { |
550 | case (UInt16)LSO_Enums.BuiltIn_Functions.llSay: | 550 | case (UInt16)LSO_Enums.BuiltIn_Functions.llSay: |
551 | il.Emit(OpCodes.Call, typeof(Console).GetMethod | 551 | il.Emit(OpCodes.Call, typeof(Console).GetMethod |
552 | ("WriteLine", new Type[] { typeof(string) })); | 552 | ("WriteLine", new Type[] { typeof(string) })); |
553 | break; | 553 | break; |
554 | } | 554 | } |
555 | break; | 555 | break; |
556 | 556 | ||
557 | 557 | ||
558 | // RETURN | 558 | // RETURN |
559 | case (UInt16)LSO_Enums.Operation_Table.RETURN: | 559 | case (UInt16)LSO_Enums.Operation_Table.RETURN: |
560 | SendToDebug("Last OPCODE was return command. Code chunk execution complete."); | 560 | SendToDebug("Last OPCODE was return command. Code chunk execution complete."); |
561 | FoundRet = true; | 561 | FoundRet = true; |
562 | break; | 562 | break; |
563 | } | 563 | } |
564 | //fs.Seek(rPos, SeekOrigin.Begin); | 564 | //fs.Seek(rPos, SeekOrigin.Begin); |
565 | 565 | ||
566 | } | 566 | } |
567 | 567 | ||
568 | 568 | ||
569 | /* | 569 | /* |
570 | * CATCH | 570 | * CATCH |
571 | */ | 571 | */ |
572 | SendToDebug("CLR:" + eventname + ":il.BeginCatchBlock(typeof(Exception));"); | 572 | SendToDebug("CLR:" + eventname + ":il.BeginCatchBlock(typeof(Exception));"); |
573 | il.BeginCatchBlock(typeof(Exception)); | 573 | il.BeginCatchBlock(typeof(Exception)); |
574 | 574 | ||
575 | // Push "Hello World!" string to stack | 575 | // Push "Hello World!" string to stack |
576 | SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr..."); | 576 | SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr..."); |
577 | il.Emit(OpCodes.Ldstr, "Execption executing dynamic CLR function " + eventname + ": "); | 577 | il.Emit(OpCodes.Ldstr, "Execption executing dynamic CLR function " + eventname + ": "); |
578 | 578 | ||
579 | //call void [mscorlib]System.Console::WriteLine(string) | 579 | //call void [mscorlib]System.Console::WriteLine(string) |
580 | SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); | 580 | SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); |
581 | il.Emit(OpCodes.Call, typeof(Console).GetMethod | 581 | il.Emit(OpCodes.Call, typeof(Console).GetMethod |
582 | ("Write", new Type[] { typeof(string) })); | 582 | ("Write", new Type[] { typeof(string) })); |
583 | 583 | ||
584 | //callvirt instance string [mscorlib]System.Exception::get_Message() | 584 | //callvirt instance string [mscorlib]System.Exception::get_Message() |
585 | SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Callvirt..."); | 585 | SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Callvirt..."); |
586 | il.Emit(OpCodes.Callvirt, typeof(Exception).GetMethod | 586 | il.Emit(OpCodes.Callvirt, typeof(Exception).GetMethod |
587 | ("get_Message")); | 587 | ("get_Message")); |
588 | 588 | ||
589 | //call void [mscorlib]System.Console::WriteLine(string) | 589 | //call void [mscorlib]System.Console::WriteLine(string) |
590 | SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); | 590 | SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); |
591 | il.Emit(OpCodes.Call, typeof(Console).GetMethod | 591 | il.Emit(OpCodes.Call, typeof(Console).GetMethod |
592 | ("WriteLine", new Type[] { typeof(string) })); | 592 | ("WriteLine", new Type[] { typeof(string) })); |
593 | 593 | ||
594 | /* | 594 | /* |
595 | * CLR END TRY | 595 | * CLR END TRY |
596 | */ | 596 | */ |
597 | //SendToDebug("CLR:" + eventname + ":il.EndExceptionBlock();"); | 597 | //SendToDebug("CLR:" + eventname + ":il.EndExceptionBlock();"); |
598 | il.EndExceptionBlock(); | 598 | il.EndExceptionBlock(); |
599 | // Push "Return from current method, with return value if present" to stack | 599 | // Push "Return from current method, with return value if present" to stack |
600 | il.Emit(OpCodes.Ret); | 600 | il.Emit(OpCodes.Ret); |
601 | 601 | ||
602 | 602 | ||
603 | 603 | ||
604 | return myCodeChunk; | 604 | return myCodeChunk; |
605 | 605 | ||
606 | } | 606 | } |
607 | } | 607 | } |
608 | } | 608 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Struct.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Struct.cs index 3b91e9f..66c6c5e 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Struct.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/LSLEngine/LSLHandler/LSO_Struct.cs | |||
@@ -1,105 +1,105 @@ | |||
1 | 1 | ||
2 | using System; | 2 | using System; |
3 | using System.Collections.Generic; | 3 | using System.Collections.Generic; |
4 | using System.Text; | 4 | using System.Text; |
5 | 5 | ||
6 | namespace OpenSim.ScriptEngines.LSL | 6 | namespace OpenSim.ScriptEngines.LSL |
7 | { | 7 | { |
8 | static class LSO_Struct | 8 | static class LSO_Struct |
9 | { | 9 | { |
10 | 10 | ||
11 | public struct Header | 11 | public struct Header |
12 | { | 12 | { |
13 | public UInt32 TM; | 13 | public UInt32 TM; |
14 | public UInt32 IP; | 14 | public UInt32 IP; |
15 | public UInt32 VN; | 15 | public UInt32 VN; |
16 | public UInt32 BP; | 16 | public UInt32 BP; |
17 | public UInt32 SP; | 17 | public UInt32 SP; |
18 | public UInt32 HR; | 18 | public UInt32 HR; |
19 | public UInt32 HP; | 19 | public UInt32 HP; |
20 | public UInt32 CS; | 20 | public UInt32 CS; |
21 | public UInt32 NS; | 21 | public UInt32 NS; |
22 | public UInt32 CE; | 22 | public UInt32 CE; |
23 | public UInt32 IE; | 23 | public UInt32 IE; |
24 | public UInt32 ER; | 24 | public UInt32 ER; |
25 | public UInt32 FR; | 25 | public UInt32 FR; |
26 | public UInt32 SLR; | 26 | public UInt32 SLR; |
27 | public UInt32 GVR; | 27 | public UInt32 GVR; |
28 | public UInt32 GFR; | 28 | public UInt32 GFR; |
29 | public UInt32 PR; | 29 | public UInt32 PR; |
30 | public UInt32 ESR; | 30 | public UInt32 ESR; |
31 | public UInt32 SR; | 31 | public UInt32 SR; |
32 | public UInt64 NCE; | 32 | public UInt64 NCE; |
33 | public UInt64 NIE; | 33 | public UInt64 NIE; |
34 | public UInt64 NER; | 34 | public UInt64 NER; |
35 | } | 35 | } |
36 | 36 | ||
37 | public struct StaticBlock | 37 | public struct StaticBlock |
38 | { | 38 | { |
39 | public UInt32 Static_Chunk_Header_Size; | 39 | public UInt32 Static_Chunk_Header_Size; |
40 | public byte ObjectType; | 40 | public byte ObjectType; |
41 | public byte Unknown; | 41 | public byte Unknown; |
42 | public byte[] BlockVariable; | 42 | public byte[] BlockVariable; |
43 | } | 43 | } |
44 | /* Not actually a structure | 44 | /* Not actually a structure |
45 | public struct StaticBlockVariable | 45 | public struct StaticBlockVariable |
46 | { | 46 | { |
47 | public UInt32 Integer1; | 47 | public UInt32 Integer1; |
48 | public UInt32 Float1; | 48 | public UInt32 Float1; |
49 | public UInt32 HeapPointer_String; | 49 | public UInt32 HeapPointer_String; |
50 | public UInt32 HeapPointer_Key; | 50 | public UInt32 HeapPointer_Key; |
51 | public byte[] Vector_12; | 51 | public byte[] Vector_12; |
52 | public byte[] Rotation_16; | 52 | public byte[] Rotation_16; |
53 | public UInt32 Pointer_List_Structure; | 53 | public UInt32 Pointer_List_Structure; |
54 | } */ | 54 | } */ |
55 | public struct HeapBlock | 55 | public struct HeapBlock |
56 | { | 56 | { |
57 | public UInt32 DataBlockSize; | 57 | public UInt32 DataBlockSize; |
58 | public byte ObjectType; | 58 | public byte ObjectType; |
59 | public UInt16 ReferenceCount; | 59 | public UInt16 ReferenceCount; |
60 | public byte[] Data; | 60 | public byte[] Data; |
61 | } | 61 | } |
62 | public struct StateFrameBlock | 62 | public struct StateFrameBlock |
63 | { | 63 | { |
64 | public UInt32 StateCount; | 64 | public UInt32 StateCount; |
65 | public StatePointerBlock[] StatePointer; | 65 | public StatePointerBlock[] StatePointer; |
66 | } | 66 | } |
67 | public struct StatePointerBlock | 67 | public struct StatePointerBlock |
68 | { | 68 | { |
69 | public UInt32 Location; | 69 | public UInt32 Location; |
70 | public System.Collections.BitArray EventMask; | 70 | public System.Collections.BitArray EventMask; |
71 | public StateBlock StateBlock; | 71 | public StateBlock StateBlock; |
72 | } | 72 | } |
73 | public struct StateBlock | 73 | public struct StateBlock |
74 | { | 74 | { |
75 | public UInt32 StartPos; | 75 | public UInt32 StartPos; |
76 | public UInt32 EndPos; | 76 | public UInt32 EndPos; |
77 | public UInt32 HeaderSize; | 77 | public UInt32 HeaderSize; |
78 | public byte Unknown; | 78 | public byte Unknown; |
79 | public StateBlockHandler[] StateBlockHandlers; | 79 | public StateBlockHandler[] StateBlockHandlers; |
80 | } | 80 | } |
81 | public struct StateBlockHandler | 81 | public struct StateBlockHandler |
82 | { | 82 | { |
83 | public UInt32 CodeChunkPointer; | 83 | public UInt32 CodeChunkPointer; |
84 | public UInt32 CallFrameSize; | 84 | public UInt32 CallFrameSize; |
85 | } | 85 | } |
86 | public struct FunctionBlock | 86 | public struct FunctionBlock |
87 | { | 87 | { |
88 | public UInt32 FunctionCount; | 88 | public UInt32 FunctionCount; |
89 | public UInt32[] CodeChunkPointer; | 89 | public UInt32[] CodeChunkPointer; |
90 | } | 90 | } |
91 | public struct CodeChunk | 91 | public struct CodeChunk |
92 | { | 92 | { |
93 | public UInt32 CodeChunkHeaderSize; | 93 | public UInt32 CodeChunkHeaderSize; |
94 | public string Comment; | 94 | public string Comment; |
95 | public System.Collections.Generic.List<CodeChunkArgument> CodeChunkArguments; | 95 | public System.Collections.Generic.List<CodeChunkArgument> CodeChunkArguments; |
96 | public byte EndMarker; | 96 | public byte EndMarker; |
97 | public byte ReturnType; | 97 | public byte ReturnType; |
98 | } | 98 | } |
99 | public struct CodeChunkArgument | 99 | public struct CodeChunkArgument |
100 | { | 100 | { |
101 | public byte FunctionReturnType; | 101 | public byte FunctionReturnType; |
102 | public byte NullString; | 102 | public byte NullString; |
103 | } | 103 | } |
104 | } | 104 | } |
105 | } | 105 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Script.cs b/OpenSim/Region/Environment/Scenes/scripting/Script.cs index 99d7d04..40825c0 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Script.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Script.cs | |||
@@ -1,64 +1,64 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using OpenSim.Region.Environment.Scenes; | 28 | using OpenSim.Region.Environment.Scenes; |
29 | 29 | ||
30 | namespace OpenSim.Region.Scripting | 30 | namespace OpenSim.Region.Scripting |
31 | { | 31 | { |
32 | public interface IScript | 32 | public interface IScript |
33 | { | 33 | { |
34 | void Initialise(ScriptInfo scriptInfo); | 34 | void Initialise(ScriptInfo scriptInfo); |
35 | string getName(); | 35 | string getName(); |
36 | } | 36 | } |
37 | 37 | ||
38 | public class TestScript : IScript | 38 | public class TestScript : IScript |
39 | { | 39 | { |
40 | ScriptInfo script; | 40 | ScriptInfo script; |
41 | 41 | ||
42 | public string getName() | 42 | public string getName() |
43 | { | 43 | { |
44 | return "TestScript 0.1"; | 44 | return "TestScript 0.1"; |
45 | } | 45 | } |
46 | 46 | ||
47 | public void Initialise(ScriptInfo scriptInfo) | 47 | public void Initialise(ScriptInfo scriptInfo) |
48 | { | 48 | { |
49 | script = scriptInfo; | 49 | script = scriptInfo; |
50 | script.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame); | 50 | script.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame); |
51 | script.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence); | 51 | script.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence); |
52 | } | 52 | } |
53 | 53 | ||
54 | void events_OnNewPresence(ScenePresence presence) | 54 | void events_OnNewPresence(ScenePresence presence) |
55 | { | 55 | { |
56 | script.logger.Verbose("Hello " + presence.firstname.ToString() + "!"); | 56 | script.logger.Verbose("Hello " + presence.firstname.ToString() + "!"); |
57 | } | 57 | } |
58 | 58 | ||
59 | void events_OnFrame() | 59 | void events_OnFrame() |
60 | { | 60 | { |
61 | //script.logger.Verbose("Hello World!"); | 61 | //script.logger.Verbose("Hello World!"); |
62 | } | 62 | } |
63 | } | 63 | } |
64 | } | 64 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs index a8f6aa5..b4f6a05 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs | |||
@@ -1,32 +1,32 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using Key = libsecondlife.LLUUID; | 4 | using Key = libsecondlife.LLUUID; |
5 | using Rotation = libsecondlife.LLQuaternion; | 5 | using Rotation = libsecondlife.LLQuaternion; |
6 | using Vector = libsecondlife.LLVector3; | 6 | using Vector = libsecondlife.LLVector3; |
7 | using LSLList = System.Collections.Generic.List<string>; | 7 | using LSLList = System.Collections.Generic.List<string>; |
8 | 8 | ||
9 | 9 | ||
10 | using OpenSim.Region.Environment.Scenes; | 10 | using OpenSim.Region.Environment.Scenes; |
11 | 11 | ||
12 | namespace OpenSim.Region.Scripting | 12 | namespace OpenSim.Region.Scripting |
13 | { | 13 | { |
14 | // This class is to be used for engines which may not be able to access the Scene directly. | 14 | // This class is to be used for engines which may not be able to access the Scene directly. |
15 | // Scene access is preffered, but obviously not possible on some non-.NET languages. | 15 | // Scene access is preffered, but obviously not possible on some non-.NET languages. |
16 | public class ScriptAPI | 16 | public class ScriptAPI |
17 | { | 17 | { |
18 | Scene scene; | 18 | Scene scene; |
19 | ScriptInterpretedAPI interpretedAPI; | 19 | ScriptInterpretedAPI interpretedAPI; |
20 | 20 | ||
21 | public ScriptAPI(Scene world) | 21 | public ScriptAPI(Scene world) |
22 | { | 22 | { |
23 | scene = world; | 23 | scene = world; |
24 | interpretedAPI = new ScriptInterpretedAPI(); | 24 | interpretedAPI = new ScriptInterpretedAPI(); |
25 | } | 25 | } |
26 | 26 | ||
27 | public Object CallMethod(String method, Object[] args) | 27 | public Object CallMethod(String method, Object[] args) |
28 | { | 28 | { |
29 | return null; | 29 | return null; |
30 | } | 30 | } |
31 | } | 31 | } |
32 | } | 32 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptInfo.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptInfo.cs index c3be22a..4a6086c 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/ScriptInfo.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptInfo.cs | |||
@@ -1,58 +1,58 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using OpenSim.Framework.Console; | 28 | using OpenSim.Framework.Console; |
29 | using OpenSim.Region.Environment.Scenes; | 29 | using OpenSim.Region.Environment.Scenes; |
30 | 30 | ||
31 | namespace OpenSim.Region.Scripting | 31 | namespace OpenSim.Region.Scripting |
32 | { | 32 | { |
33 | /// <summary> | 33 | /// <summary> |
34 | /// Class which provides access to the world | 34 | /// Class which provides access to the world |
35 | /// </summary> | 35 | /// </summary> |
36 | public class ScriptInfo | 36 | public class ScriptInfo |
37 | { | 37 | { |
38 | // Reference to world.eventsManager provided for convenience | 38 | // Reference to world.eventsManager provided for convenience |
39 | public EventManager events; | 39 | public EventManager events; |
40 | 40 | ||
41 | // The main world | 41 | // The main world |
42 | public Scene world; | 42 | public Scene world; |
43 | 43 | ||
44 | // The console | 44 | // The console |
45 | public LogBase logger; | 45 | public LogBase logger; |
46 | 46 | ||
47 | // API Access | 47 | // API Access |
48 | public ScriptAPI api; | 48 | public ScriptAPI api; |
49 | 49 | ||
50 | public ScriptInfo(Scene scene) | 50 | public ScriptInfo(Scene scene) |
51 | { | 51 | { |
52 | world = scene; | 52 | world = scene; |
53 | events = world.EventManager; | 53 | events = world.EventManager; |
54 | logger = MainLog.Instance; | 54 | logger = MainLog.Instance; |
55 | api = new ScriptAPI(scene); | 55 | api = new ScriptAPI(scene); |
56 | } | 56 | } |
57 | } | 57 | } |
58 | } | 58 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedAPI.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedAPI.cs index 085d97e..b4a6019 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedAPI.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedAPI.cs | |||
@@ -1,206 +1,206 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using Key = libsecondlife.LLUUID; | 4 | using Key = libsecondlife.LLUUID; |
5 | using Rotation = libsecondlife.LLQuaternion; | 5 | using Rotation = libsecondlife.LLQuaternion; |
6 | using Vector = libsecondlife.LLVector3; | 6 | using Vector = libsecondlife.LLVector3; |
7 | using LSLList = System.Collections.Generic.List<string>; | 7 | using LSLList = System.Collections.Generic.List<string>; |
8 | 8 | ||
9 | using OpenSim.Region.Environment.Scenes; | 9 | using OpenSim.Region.Environment.Scenes; |
10 | 10 | ||
11 | namespace OpenSim.Region.Scripting | 11 | namespace OpenSim.Region.Scripting |
12 | { | 12 | { |
13 | /// <summary> | 13 | /// <summary> |
14 | /// A class inteded to act as an API for LSL-styled interpreted languages | 14 | /// A class inteded to act as an API for LSL-styled interpreted languages |
15 | /// </summary> | 15 | /// </summary> |
16 | /// <remarks>Avoid at all costs. This should ONLY be used for LSL.</remarks> | 16 | /// <remarks>Avoid at all costs. This should ONLY be used for LSL.</remarks> |
17 | class ScriptInterpretedAPI | 17 | class ScriptInterpretedAPI |
18 | { | 18 | { |
19 | public int osAbs(int val) | 19 | public int osAbs(int val) |
20 | { | 20 | { |
21 | return Math.Abs(val); | 21 | return Math.Abs(val); |
22 | } | 22 | } |
23 | 23 | ||
24 | public float osAcos(float val) | 24 | public float osAcos(float val) |
25 | { | 25 | { |
26 | return (float)Math.Acos(val); | 26 | return (float)Math.Acos(val); |
27 | } | 27 | } |
28 | 28 | ||
29 | [Obsolete("Unimplemented")] | 29 | [Obsolete("Unimplemented")] |
30 | public void osAddToLandPassList(Key avatar, float hours) | 30 | public void osAddToLandPassList(Key avatar, float hours) |
31 | { | 31 | { |
32 | OpenSim.Framework.Console.MainLog.Instance.Warn("Unimplemented function called by script: osAddToLandPassList(Key avatar, float hours)"); | 32 | OpenSim.Framework.Console.MainLog.Instance.Warn("Unimplemented function called by script: osAddToLandPassList(Key avatar, float hours)"); |
33 | return; | 33 | return; |
34 | } | 34 | } |
35 | 35 | ||
36 | [Obsolete("Unimplemented")] | 36 | [Obsolete("Unimplemented")] |
37 | public void osAdjustSoundVolume(float volume) | 37 | public void osAdjustSoundVolume(float volume) |
38 | { | 38 | { |
39 | OpenSim.Framework.Console.MainLog.Instance.Warn("Unimplemented function called by script: osAdjustSoundVolume(float volume)"); | 39 | OpenSim.Framework.Console.MainLog.Instance.Warn("Unimplemented function called by script: osAdjustSoundVolume(float volume)"); |
40 | return; | 40 | return; |
41 | } | 41 | } |
42 | 42 | ||
43 | [Obsolete("Unimplemented")] | 43 | [Obsolete("Unimplemented")] |
44 | public void osAllowInventoryDrop(int add) | 44 | public void osAllowInventoryDrop(int add) |
45 | { | 45 | { |
46 | return; | 46 | return; |
47 | } | 47 | } |
48 | 48 | ||
49 | [Obsolete("Unimplemented")] | 49 | [Obsolete("Unimplemented")] |
50 | public float osAngleBetween(Rotation a, Rotation b) | 50 | public float osAngleBetween(Rotation a, Rotation b) |
51 | { | 51 | { |
52 | Axiom.Math.Quaternion axA = new Axiom.Math.Quaternion(a.W, a.X, a.Y, a.Z); | 52 | Axiom.Math.Quaternion axA = new Axiom.Math.Quaternion(a.W, a.X, a.Y, a.Z); |
53 | Axiom.Math.Quaternion axB = new Axiom.Math.Quaternion(b.W, b.X, b.Y, b.Z); | 53 | Axiom.Math.Quaternion axB = new Axiom.Math.Quaternion(b.W, b.X, b.Y, b.Z); |
54 | 54 | ||
55 | return 0; | 55 | return 0; |
56 | } | 56 | } |
57 | 57 | ||
58 | [Obsolete("Unimplemented")] | 58 | [Obsolete("Unimplemented")] |
59 | public void osApplyImpulse(Vector force, int local) | 59 | public void osApplyImpulse(Vector force, int local) |
60 | { | 60 | { |
61 | return; | 61 | return; |
62 | } | 62 | } |
63 | 63 | ||
64 | [Obsolete("Unimplemented")] | 64 | [Obsolete("Unimplemented")] |
65 | public void osApplyRotationalImpulse(Vector force, int local) | 65 | public void osApplyRotationalImpulse(Vector force, int local) |
66 | { | 66 | { |
67 | return; | 67 | return; |
68 | } | 68 | } |
69 | 69 | ||
70 | public float osAsin(float val) | 70 | public float osAsin(float val) |
71 | { | 71 | { |
72 | return (float)Math.Asin(val); | 72 | return (float)Math.Asin(val); |
73 | } | 73 | } |
74 | 74 | ||
75 | public float osAtan2(float x, float y) | 75 | public float osAtan2(float x, float y) |
76 | { | 76 | { |
77 | return (float)Math.Atan2(x, y); | 77 | return (float)Math.Atan2(x, y); |
78 | } | 78 | } |
79 | 79 | ||
80 | [Obsolete("Unimplemented")] | 80 | [Obsolete("Unimplemented")] |
81 | public void osAttachToAvatar(Key avatar, int attachmentPoint) | 81 | public void osAttachToAvatar(Key avatar, int attachmentPoint) |
82 | { | 82 | { |
83 | return; | 83 | return; |
84 | } | 84 | } |
85 | 85 | ||
86 | [Obsolete("Unimplemented")] | 86 | [Obsolete("Unimplemented")] |
87 | public Key osAvatarOnSitTarget() | 87 | public Key osAvatarOnSitTarget() |
88 | { | 88 | { |
89 | return Key.Zero; | 89 | return Key.Zero; |
90 | } | 90 | } |
91 | 91 | ||
92 | public Rotation osAxes2Rot(Vector fwd, Vector left, Vector up) | 92 | public Rotation osAxes2Rot(Vector fwd, Vector left, Vector up) |
93 | { | 93 | { |
94 | Axiom.Math.Quaternion axQ = new Axiom.Math.Quaternion(); | 94 | Axiom.Math.Quaternion axQ = new Axiom.Math.Quaternion(); |
95 | Axiom.Math.Vector3 axFwd = new Axiom.Math.Vector3(fwd.X, fwd.Y, fwd.Z); | 95 | Axiom.Math.Vector3 axFwd = new Axiom.Math.Vector3(fwd.X, fwd.Y, fwd.Z); |
96 | Axiom.Math.Vector3 axLeft = new Axiom.Math.Vector3(left.X, left.Y, left.Z); | 96 | Axiom.Math.Vector3 axLeft = new Axiom.Math.Vector3(left.X, left.Y, left.Z); |
97 | Axiom.Math.Vector3 axUp = new Axiom.Math.Vector3(up.X, up.Y, up.Z); | 97 | Axiom.Math.Vector3 axUp = new Axiom.Math.Vector3(up.X, up.Y, up.Z); |
98 | 98 | ||
99 | axQ.FromAxes(axFwd, axLeft, axUp); | 99 | axQ.FromAxes(axFwd, axLeft, axUp); |
100 | 100 | ||
101 | return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w); | 101 | return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w); |
102 | } | 102 | } |
103 | 103 | ||
104 | public Rotation osAxisAngle2Rot(Vector axis, float angle) | 104 | public Rotation osAxisAngle2Rot(Vector axis, float angle) |
105 | { | 105 | { |
106 | Axiom.Math.Quaternion axQ = Axiom.Math.Quaternion.FromAngleAxis(angle, new Axiom.Math.Vector3(axis.X, axis.Y, axis.Z)); | 106 | Axiom.Math.Quaternion axQ = Axiom.Math.Quaternion.FromAngleAxis(angle, new Axiom.Math.Vector3(axis.X, axis.Y, axis.Z)); |
107 | 107 | ||
108 | return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w); | 108 | return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w); |
109 | } | 109 | } |
110 | 110 | ||
111 | public string osBase64ToString(string str) | 111 | public string osBase64ToString(string str) |
112 | { | 112 | { |
113 | Encoding enc = System.Text.Encoding.UTF8; | 113 | Encoding enc = System.Text.Encoding.UTF8; |
114 | return enc.GetString(Convert.FromBase64String(str)); | 114 | return enc.GetString(Convert.FromBase64String(str)); |
115 | } | 115 | } |
116 | 116 | ||
117 | [Obsolete("Unimplemented")] | 117 | [Obsolete("Unimplemented")] |
118 | public void osBreakAllLinks() | 118 | public void osBreakAllLinks() |
119 | { | 119 | { |
120 | return; | 120 | return; |
121 | } | 121 | } |
122 | 122 | ||
123 | [Obsolete("Unimplemented")] | 123 | [Obsolete("Unimplemented")] |
124 | public void osBreakLink() | 124 | public void osBreakLink() |
125 | { | 125 | { |
126 | return; | 126 | return; |
127 | } | 127 | } |
128 | 128 | ||
129 | public LSLList osCSV2List(string src) | 129 | public LSLList osCSV2List(string src) |
130 | { | 130 | { |
131 | LSLList retVal = new LSLList(); | 131 | LSLList retVal = new LSLList(); |
132 | retVal.AddRange(src.Split(',')); | 132 | retVal.AddRange(src.Split(',')); |
133 | 133 | ||
134 | return retVal; | 134 | return retVal; |
135 | } | 135 | } |
136 | 136 | ||
137 | public int osCeil(float val) | 137 | public int osCeil(float val) |
138 | { | 138 | { |
139 | return (int)Math.Ceiling(val); | 139 | return (int)Math.Ceiling(val); |
140 | } | 140 | } |
141 | 141 | ||
142 | [Obsolete("Unimplemented")] | 142 | [Obsolete("Unimplemented")] |
143 | public void osCloseRemoteDataChannel(Key channel) | 143 | public void osCloseRemoteDataChannel(Key channel) |
144 | { | 144 | { |
145 | return; | 145 | return; |
146 | } | 146 | } |
147 | 147 | ||
148 | [Obsolete("Unimplemented")] | 148 | [Obsolete("Unimplemented")] |
149 | public float osCloud(Vector offset) | 149 | public float osCloud(Vector offset) |
150 | { | 150 | { |
151 | return 0.0f; | 151 | return 0.0f; |
152 | } | 152 | } |
153 | 153 | ||
154 | [Obsolete("Unimplemented")] | 154 | [Obsolete("Unimplemented")] |
155 | public void osCollisionFilter(string name, Key id, int accept) | 155 | public void osCollisionFilter(string name, Key id, int accept) |
156 | { | 156 | { |
157 | return; | 157 | return; |
158 | } | 158 | } |
159 | 159 | ||
160 | [Obsolete("Unimplemented")] | 160 | [Obsolete("Unimplemented")] |
161 | public void osCollisionSprite(string impact_sprite) | 161 | public void osCollisionSprite(string impact_sprite) |
162 | { | 162 | { |
163 | return; | 163 | return; |
164 | } | 164 | } |
165 | 165 | ||
166 | public float osCos(float theta) | 166 | public float osCos(float theta) |
167 | { | 167 | { |
168 | return (float)Math.Cos(theta); | 168 | return (float)Math.Cos(theta); |
169 | } | 169 | } |
170 | 170 | ||
171 | [Obsolete("Unimplemented")] | 171 | [Obsolete("Unimplemented")] |
172 | public void osCreateLink(Key target, int parent) | 172 | public void osCreateLink(Key target, int parent) |
173 | { | 173 | { |
174 | return; | 174 | return; |
175 | } | 175 | } |
176 | 176 | ||
177 | [Obsolete("Partially Unimplemented")] | 177 | [Obsolete("Partially Unimplemented")] |
178 | public LSLList osDeleteSubList(LSLList src, int start, int end) | 178 | public LSLList osDeleteSubList(LSLList src, int start, int end) |
179 | { | 179 | { |
180 | if (start < 0 || end < 0) | 180 | if (start < 0 || end < 0) |
181 | { | 181 | { |
182 | throw new Exception("Unsupported at this time."); | 182 | throw new Exception("Unsupported at this time."); |
183 | } | 183 | } |
184 | 184 | ||
185 | src.RemoveRange(start, start - end + 1); | 185 | src.RemoveRange(start, start - end + 1); |
186 | return src; | 186 | return src; |
187 | } | 187 | } |
188 | 188 | ||
189 | [Obsolete("Partially Unimplemented")] | 189 | [Obsolete("Partially Unimplemented")] |
190 | public string osDeleteSubString(string src, int start, int end) | 190 | public string osDeleteSubString(string src, int start, int end) |
191 | { | 191 | { |
192 | if (start < 0 || end < 0) | 192 | if (start < 0 || end < 0) |
193 | { | 193 | { |
194 | throw new Exception("Unsupported at this time."); | 194 | throw new Exception("Unsupported at this time."); |
195 | } | 195 | } |
196 | 196 | ||
197 | return src.Remove(start, start - end + 1); | 197 | return src.Remove(start, start - end + 1); |
198 | } | 198 | } |
199 | 199 | ||
200 | [Obsolete("Unimplemented")] | 200 | [Obsolete("Unimplemented")] |
201 | public void osDetachFromAvatar(Key avatar) | 201 | public void osDetachFromAvatar(Key avatar) |
202 | { | 202 | { |
203 | return; | 203 | return; |
204 | } | 204 | } |
205 | } | 205 | } |
206 | } | 206 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedEvents.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedEvents.cs index 7743186..d6456a6 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedEvents.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptInterpretedEvents.cs | |||
@@ -1,16 +1,16 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using OpenSim.Region.Environment.Scenes; | 4 | using OpenSim.Region.Environment.Scenes; |
5 | using libsecondlife; | 5 | using libsecondlife; |
6 | using Key = libsecondlife.LLUUID; | 6 | using Key = libsecondlife.LLUUID; |
7 | 7 | ||
8 | namespace OpenSim.Region.Scripting | 8 | namespace OpenSim.Region.Scripting |
9 | { | 9 | { |
10 | 10 | ||
11 | public class ScriptInterpretedEvents | 11 | public class ScriptInterpretedEvents |
12 | { | 12 | { |
13 | public delegate void OnTouchStartDelegate(Key user); | 13 | public delegate void OnTouchStartDelegate(Key user); |
14 | public event OnTouchStartDelegate OnTouchStart; | 14 | public event OnTouchStartDelegate OnTouchStart; |
15 | } | 15 | } |
16 | } | 16 | } |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs index 7a08735..27e831b 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs | |||
@@ -1,107 +1,107 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using OpenSim.Framework.Console; | 29 | using OpenSim.Framework.Console; |
30 | using OpenSim.Region.Environment.Scenes; | 30 | using OpenSim.Region.Environment.Scenes; |
31 | 31 | ||
32 | namespace OpenSim.Region.Scripting | 32 | namespace OpenSim.Region.Scripting |
33 | { | 33 | { |
34 | public class ScriptManager | 34 | public class ScriptManager |
35 | { | 35 | { |
36 | List<IScript> scripts = new List<IScript>(); | 36 | List<IScript> scripts = new List<IScript>(); |
37 | Scene scene; | 37 | Scene scene; |
38 | Dictionary<string, IScriptCompiler> compilers = new Dictionary<string, IScriptCompiler>(); | 38 | Dictionary<string, IScriptCompiler> compilers = new Dictionary<string, IScriptCompiler>(); |
39 | 39 | ||
40 | private void LoadFromCompiler(Dictionary<string, IScript> compiledscripts) | 40 | private void LoadFromCompiler(Dictionary<string, IScript> compiledscripts) |
41 | { | 41 | { |
42 | foreach (KeyValuePair<string, IScript> script in compiledscripts) | 42 | foreach (KeyValuePair<string, IScript> script in compiledscripts) |
43 | { | 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. | 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 | MainLog.Instance.Verbose("Loading " + script.Key); | 45 | MainLog.Instance.Verbose("Loading " + script.Key); |
46 | script.Value.Initialise(scriptInfo); | 46 | script.Value.Initialise(scriptInfo); |
47 | scripts.Add(script.Value); | 47 | scripts.Add(script.Value); |
48 | } | 48 | } |
49 | MainLog.Instance.Verbose("Finished loading " + compiledscripts.Count.ToString() + " script(s)"); | 49 | MainLog.Instance.Verbose("Finished loading " + compiledscripts.Count.ToString() + " script(s)"); |
50 | } | 50 | } |
51 | 51 | ||
52 | public ScriptManager(Scene world) | 52 | public ScriptManager(Scene world) |
53 | { | 53 | { |
54 | scene = world; | 54 | scene = world; |
55 | 55 | ||
56 | // Default Engines | 56 | // Default Engines |
57 | CSharpScriptEngine csharpCompiler = new CSharpScriptEngine(); | 57 | CSharpScriptEngine csharpCompiler = new CSharpScriptEngine(); |
58 | compilers.Add(csharpCompiler.FileExt(),csharpCompiler); | 58 | compilers.Add(csharpCompiler.FileExt(),csharpCompiler); |
59 | 59 | ||
60 | JScriptEngine jscriptCompiler = new JScriptEngine(); | 60 | JScriptEngine jscriptCompiler = new JScriptEngine(); |
61 | compilers.Add(jscriptCompiler.FileExt(), jscriptCompiler); | 61 | compilers.Add(jscriptCompiler.FileExt(), jscriptCompiler); |
62 | 62 | ||
63 | JavaEngine javaCompiler = new JavaEngine(); | 63 | JavaEngine javaCompiler = new JavaEngine(); |
64 | compilers.Add(javaCompiler.FileExt(), javaCompiler); | 64 | compilers.Add(javaCompiler.FileExt(), javaCompiler); |
65 | } | 65 | } |
66 | 66 | ||
67 | public void Compile(string filename) | 67 | public void Compile(string filename) |
68 | { | 68 | { |
69 | foreach (KeyValuePair<string, IScriptCompiler> compiler in compilers) | 69 | foreach (KeyValuePair<string, IScriptCompiler> compiler in compilers) |
70 | { | 70 | { |
71 | if (filename.EndsWith(compiler.Key)) | 71 | if (filename.EndsWith(compiler.Key)) |
72 | { | 72 | { |
73 | LoadFromCompiler(compiler.Value.compile(filename)); | 73 | LoadFromCompiler(compiler.Value.compile(filename)); |
74 | break; | 74 | break; |
75 | } | 75 | } |
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||
79 | public void RunScriptCmd(string[] args) | 79 | public void RunScriptCmd(string[] args) |
80 | { | 80 | { |
81 | switch (args[0]) | 81 | switch (args[0]) |
82 | { | 82 | { |
83 | case "load": | 83 | case "load": |
84 | Compile(args[1]); | 84 | Compile(args[1]); |
85 | break; | 85 | break; |
86 | 86 | ||
87 | default: | 87 | default: |
88 | MainLog.Instance.Error("Unknown script command"); | 88 | MainLog.Instance.Error("Unknown script command"); |
89 | break; | 89 | break; |
90 | } | 90 | } |
91 | } | 91 | } |
92 | 92 | ||
93 | public void AddPreCompiledScript(IScript script) | 93 | public void AddPreCompiledScript(IScript script) |
94 | { | 94 | { |
95 | MainLog.Instance.Verbose("Loading script " + script.getName()); | 95 | MainLog.Instance.Verbose("Loading script " + script.getName()); |
96 | ScriptInfo scriptInfo = new ScriptInfo(scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. | 96 | ScriptInfo scriptInfo = new ScriptInfo(scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. |
97 | script.Initialise(scriptInfo); | 97 | script.Initialise(scriptInfo); |
98 | scripts.Add(script); | 98 | scripts.Add(script); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
102 | interface IScriptCompiler | 102 | interface IScriptCompiler |
103 | { | 103 | { |
104 | Dictionary<string,IScript> compile(string filename); | 104 | Dictionary<string,IScript> compile(string filename); |
105 | string FileExt(); | 105 | string FileExt(); |
106 | } | 106 | } |
107 | } | 107 | } |
diff --git a/OpenSim/Region/Environment/StorageManager.cs b/OpenSim/Region/Environment/StorageManager.cs index 8f8ac97..fb12c4d 100644 --- a/OpenSim/Region/Environment/StorageManager.cs +++ b/OpenSim/Region/Environment/StorageManager.cs | |||
@@ -1,60 +1,60 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | 4 | ||
5 | using OpenSim.Framework; | 5 | using OpenSim.Framework; |
6 | using OpenSim.Framework.Communications; | 6 | using OpenSim.Framework.Communications; |
7 | using OpenSim.Framework.Servers; | 7 | using OpenSim.Framework.Servers; |
8 | using OpenSim.Region.Capabilities; | 8 | using OpenSim.Region.Capabilities; |
9 | using OpenSim.Region.Environment.Scenes; | 9 | using OpenSim.Region.Environment.Scenes; |
10 | using OpenSim.Region.Interfaces; | 10 | using OpenSim.Region.Interfaces; |
11 | 11 | ||
12 | using System.Reflection; | 12 | using System.Reflection; |
13 | 13 | ||
14 | namespace OpenSim.Region.Environment | 14 | namespace OpenSim.Region.Environment |
15 | { | 15 | { |
16 | public class StorageManager | 16 | public class StorageManager |
17 | { | 17 | { |
18 | private IRegionDataStore m_dataStore; | 18 | private IRegionDataStore m_dataStore; |
19 | 19 | ||
20 | public IRegionDataStore DataStore | 20 | public IRegionDataStore DataStore |
21 | { | 21 | { |
22 | get | 22 | get |
23 | { | 23 | { |
24 | return m_dataStore; | 24 | return m_dataStore; |
25 | } | 25 | } |
26 | } | 26 | } |
27 | 27 | ||
28 | public StorageManager(IRegionDataStore storage) | 28 | public StorageManager(IRegionDataStore storage) |
29 | { | 29 | { |
30 | m_dataStore = storage; | 30 | m_dataStore = storage; |
31 | } | 31 | } |
32 | 32 | ||
33 | public StorageManager(string dllName, string dataStoreFile, string dataStoreDB) | 33 | public StorageManager(string dllName, string dataStoreFile, string dataStoreDB) |
34 | { | 34 | { |
35 | Assembly pluginAssembly = Assembly.LoadFrom(dllName); | 35 | Assembly pluginAssembly = Assembly.LoadFrom(dllName); |
36 | 36 | ||
37 | foreach (Type pluginType in pluginAssembly.GetTypes()) | 37 | foreach (Type pluginType in pluginAssembly.GetTypes()) |
38 | { | 38 | { |
39 | if (pluginType.IsPublic) | 39 | if (pluginType.IsPublic) |
40 | { | 40 | { |
41 | Type typeInterface = pluginType.GetInterface("IRegionDataStore", true); | 41 | Type typeInterface = pluginType.GetInterface("IRegionDataStore", true); |
42 | 42 | ||
43 | if (typeInterface != null) | 43 | if (typeInterface != null) |
44 | { | 44 | { |
45 | IRegionDataStore plug = (IRegionDataStore)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | 45 | IRegionDataStore plug = (IRegionDataStore)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); |
46 | plug.Initialise(dataStoreFile, dataStoreDB); | 46 | plug.Initialise(dataStoreFile, dataStoreDB); |
47 | 47 | ||
48 | m_dataStore = plug; | 48 | m_dataStore = plug; |
49 | } | 49 | } |
50 | 50 | ||
51 | typeInterface = null; | 51 | typeInterface = null; |
52 | } | 52 | } |
53 | } | 53 | } |
54 | 54 | ||
55 | pluginAssembly = null; | 55 | pluginAssembly = null; |
56 | 56 | ||
57 | //TODO: Add checking and warning to make sure it initialised. | 57 | //TODO: Add checking and warning to make sure it initialised. |
58 | } | 58 | } |
59 | } | 59 | } |
60 | } | 60 | } |