diff options
author | Jeff Ames | 2007-11-20 05:05:27 +0000 |
---|---|---|
committer | Jeff Ames | 2007-11-20 05:05:27 +0000 |
commit | 3aa73ae1c70c264d17e4e5b9a62d7227cabf3a1c (patch) | |
tree | 44a14d1390be3c1fa5981280e2ab0869d8c853df /OpenSim/Region | |
parent | Reverting my POS changes. I need to think this through a bit more. (diff) | |
download | opensim-SC-3aa73ae1c70c264d17e4e5b9a62d7227cabf3a1c.zip opensim-SC-3aa73ae1c70c264d17e4e5b9a62d7227cabf3a1c.tar.gz opensim-SC-3aa73ae1c70c264d17e4e5b9a62d7227cabf3a1c.tar.bz2 opensim-SC-3aa73ae1c70c264d17e4e5b9a62d7227cabf3a1c.tar.xz |
fixed array range out of bounds exception and reference invalidation under load in POS
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Physics/POSPlugin/POSPlugin.cs | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs index 802b7b2..bdd23ab 100644 --- a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs +++ b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs | |||
@@ -156,21 +156,25 @@ namespace OpenSim.Region.Physics.POSPlugin | |||
156 | 156 | ||
157 | private bool check_all_prims(POSCharacter c) | 157 | private bool check_all_prims(POSCharacter c) |
158 | { | 158 | { |
159 | foreach (POSPrim p in _prims) | 159 | for (int i = 0; i < _prims.Count; ++i) |
160 | { | 160 | { |
161 | if (check_collision(c, p)) | 161 | if (check_collision(c, _prims[i])) |
162 | return true; | 162 | return true; |
163 | } | 163 | } |
164 | return false; | 164 | return false; |
165 | } | 165 | } |
166 | |||
166 | public override void AddPhysicsActorTaint(PhysicsActor prim) | 167 | public override void AddPhysicsActorTaint(PhysicsActor prim) |
167 | { | 168 | { |
168 | 169 | ||
169 | } | 170 | } |
171 | |||
170 | public override void Simulate(float timeStep) | 172 | public override void Simulate(float timeStep) |
171 | { | 173 | { |
172 | foreach (POSCharacter character in _characters) | 174 | for (int i = 0; i < _characters.Count; ++i) |
173 | { | 175 | { |
176 | POSCharacter character = _characters[i]; | ||
177 | |||
174 | float oldposX = character.Position.X; | 178 | float oldposX = character.Position.X; |
175 | float oldposY = character.Position.Y; | 179 | float oldposY = character.Position.Y; |
176 | float oldposZ = character.Position.Z; | 180 | float oldposZ = character.Position.Z; |
@@ -183,6 +187,25 @@ namespace OpenSim.Region.Physics.POSPlugin | |||
183 | bool forcedZ = false; | 187 | bool forcedZ = false; |
184 | character.Position.X = character.Position.X + (character._target_velocity.X * timeStep); | 188 | character.Position.X = character.Position.X + (character._target_velocity.X * timeStep); |
185 | character.Position.Y = character.Position.Y + (character._target_velocity.Y * timeStep); | 189 | character.Position.Y = character.Position.Y + (character._target_velocity.Y * timeStep); |
190 | |||
191 | if (character.Position.Y < 0) | ||
192 | { | ||
193 | character.Position.Y = 0.1F; | ||
194 | } | ||
195 | else if (character.Position.Y >= 256) | ||
196 | { | ||
197 | character.Position.Y = 255.9F; | ||
198 | } | ||
199 | |||
200 | if (character.Position.X < 0) | ||
201 | { | ||
202 | character.Position.X = 0.1F; | ||
203 | } | ||
204 | else if (character.Position.X >= 256) | ||
205 | { | ||
206 | character.Position.X = 255.9F; | ||
207 | } | ||
208 | |||
186 | float terrainheight = _heightMap[(int)character.Position.Y * 256 + (int)character.Position.X]; | 209 | float terrainheight = _heightMap[(int)character.Position.Y * 256 + (int)character.Position.X]; |
187 | if (character.Position.Z + (character._target_velocity.Z * timeStep) < terrainheight + 2) | 210 | if (character.Position.Z + (character._target_velocity.Z * timeStep) < terrainheight + 2) |
188 | { | 211 | { |
@@ -221,24 +244,6 @@ namespace OpenSim.Region.Physics.POSPlugin | |||
221 | } | 244 | } |
222 | } | 245 | } |
223 | 246 | ||
224 | if (character.Position.Y < 0) | ||
225 | { | ||
226 | character.Position.Y = 0.1F; | ||
227 | } | ||
228 | else if (character.Position.Y >= 256) | ||
229 | { | ||
230 | character.Position.Y = 255.9F; | ||
231 | } | ||
232 | |||
233 | if (character.Position.X < 0) | ||
234 | { | ||
235 | character.Position.X = 0.1F; | ||
236 | } | ||
237 | else if (character.Position.X > 256) | ||
238 | { | ||
239 | character.Position.X = 255.9F; | ||
240 | } | ||
241 | |||
242 | character._velocity.X = (character.Position.X - oldposX) / timeStep; | 247 | character._velocity.X = (character.Position.X - oldposX) / timeStep; |
243 | character._velocity.Y = (character.Position.Y - oldposY) / timeStep; | 248 | character._velocity.Y = (character.Position.Y - oldposY) / timeStep; |
244 | 249 | ||