aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs102
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs11
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs8
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs536
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs48
-rw-r--r--OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs274
7 files changed, 890 insertions, 91 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index 6dacbba..acc3a78 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
@@ -49,7 +49,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
49 private int m_shoutdistance = 100; 49 private int m_shoutdistance = 100;
50 private int m_whisperdistance = 10; 50 private int m_whisperdistance = 10;
51 private List<Scene> m_scenes = new List<Scene>(); 51 private List<Scene> m_scenes = new List<Scene>();
52 52 private List<string> FreezeCache = new List<string>();
53 private string m_adminPrefix = "";
53 internal object m_syncy = new object(); 54 internal object m_syncy = new object();
54 55
55 internal IConfig m_config; 56 internal IConfig m_config;
@@ -76,6 +77,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
76 m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); 77 m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance);
77 m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); 78 m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance);
78 m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); 79 m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance);
80 m_adminPrefix = config.Configs["Chat"].GetString("admin_prefix", "");
79 } 81 }
80 82
81 public virtual void AddRegion(Scene scene) 83 public virtual void AddRegion(Scene scene)
@@ -171,7 +173,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
171 return; 173 return;
172 } 174 }
173 175
174 DeliverChatToAvatars(ChatSourceType.Agent, c); 176 if (FreezeCache.Contains(c.Sender.AgentId.ToString()))
177 {
178 if (c.Type != ChatTypeEnum.StartTyping || c.Type != ChatTypeEnum.StopTyping)
179 c.Sender.SendAgentAlertMessage("You may not talk as you are frozen.", false);
180 }
181 else
182 {
183 DeliverChatToAvatars(ChatSourceType.Agent, c);
184 }
175 } 185 }
176 186
177 public virtual void OnChatFromWorld(Object sender, OSChatMessage c) 187 public virtual void OnChatFromWorld(Object sender, OSChatMessage c)
@@ -185,6 +195,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
185 protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c) 195 protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
186 { 196 {
187 string fromName = c.From; 197 string fromName = c.From;
198 string fromNamePrefix = "";
188 UUID fromID = UUID.Zero; 199 UUID fromID = UUID.Zero;
189 string message = c.Message; 200 string message = c.Message;
190 IScene scene = c.Scene; 201 IScene scene = c.Scene;
@@ -207,7 +218,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
207 fromPos = avatar.AbsolutePosition; 218 fromPos = avatar.AbsolutePosition;
208 fromName = avatar.Name; 219 fromName = avatar.Name;
209 fromID = c.Sender.AgentId; 220 fromID = c.Sender.AgentId;
210 221 if (avatar.GodLevel > 200)
222 {
223 fromNamePrefix = m_adminPrefix;
224 }
211 break; 225 break;
212 226
213 case ChatSourceType.Object: 227 case ChatSourceType.Object:
@@ -227,7 +241,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
227 s.ForEachScenePresence( 241 s.ForEachScenePresence(
228 delegate(ScenePresence presence) 242 delegate(ScenePresence presence)
229 { 243 {
230 TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType); 244 ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
245 if (Presencecheck != null)
246 {
247 if (Presencecheck.IsEitherBannedOrRestricted(c.SenderUUID) != true)
248 {
249 TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix+fromName, c.Type, message, sourceType);
250 }
251 }
252
231 } 253 }
232 ); 254 );
233 } 255 }
@@ -266,25 +288,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
266 } 288 }
267 289
268 // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); 290 // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType);
269 291 if (c.Scene != null)
270 ((Scene)c.Scene).ForEachScenePresence( 292 {
271 delegate(ScenePresence presence) 293 ((Scene)c.Scene).ForEachScenePresence
272 { 294 (
273 // ignore chat from child agents 295 delegate(ScenePresence presence)
274 if (presence.IsChildAgent) return; 296 {
275 297 // ignore chat from child agents
276 IClientAPI client = presence.ControllingClient; 298 if (presence.IsChildAgent) return;
277 299
278 // don't forward SayOwner chat from objects to 300 IClientAPI client = presence.ControllingClient;
279 // non-owner agents 301
280 if ((c.Type == ChatTypeEnum.Owner) && 302 // don't forward SayOwner chat from objects to
281 (null != c.SenderObject) && 303 // non-owner agents
282 (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) 304 if ((c.Type == ChatTypeEnum.Owner) &&
283 return; 305 (null != c.SenderObject) &&
284 306 (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId))
285 client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, 307 return;
286 (byte)sourceType, (byte)ChatAudibleLevel.Fully); 308
287 }); 309 client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID,
310 (byte)sourceType, (byte)ChatAudibleLevel.Fully);
311 }
312 );
313 }
288 } 314 }
289 315
290 316
@@ -313,5 +339,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
313 presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, 339 presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName,
314 fromAgentID,(byte)src,(byte)ChatAudibleLevel.Fully); 340 fromAgentID,(byte)src,(byte)ChatAudibleLevel.Fully);
315 } 341 }
342
343 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
344 public void ParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
345 {
346 System.Threading.Timer Timer;
347 if (flags == 0)
348 {
349 FreezeCache.Add(target.ToString());
350 System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
351 Timer = new System.Threading.Timer(timeCB, target, 30000, 0);
352 Timers.Add(target, Timer);
353 }
354 else
355 {
356 FreezeCache.Remove(target.ToString());
357 Timers.TryGetValue(target, out Timer);
358 Timers.Remove(target);
359 Timer.Dispose();
360 }
361 }
362
363 private void OnEndParcelFrozen(object avatar)
364 {
365 UUID target = (UUID)avatar;
366 FreezeCache.Remove(target.ToString());
367 System.Threading.Timer Timer;
368 Timers.TryGetValue(target, out Timer);
369 Timers.Remove(target);
370 Timer.Dispose();
371 }
316 } 372 }
317} 373}
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index fdfcd10..9412735 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
@@ -172,13 +172,16 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
172 172
173 private void RetrieveInstantMessages(IClientAPI client) 173 private void RetrieveInstantMessages(IClientAPI client)
174 { 174 {
175 if (m_RestURL != "") 175 if (m_RestURL == String.Empty)
176 { 176 return;
177 m_log.DebugFormat("[OFFLINE MESSAGING] Retrieving stored messages for {0}", client.AgentId);
178 177
179 List<GridInstantMessage> msglist = SynchronousRestObjectPoster.BeginPostObject<UUID, List<GridInstantMessage>>( 178 m_log.DebugFormat("[OFFLINE MESSAGING] Retrieving stored messages for {0}", client.AgentId);
179
180 List<GridInstantMessage> msglist = SynchronousRestObjectPoster.BeginPostObject<UUID, List<GridInstantMessage>>(
180 "POST", m_RestURL + "/RetrieveMessages/", client.AgentId); 181 "POST", m_RestURL + "/RetrieveMessages/", client.AgentId);
181 182
183 if (msglist != null)
184 {
182 foreach (GridInstantMessage im in msglist) 185 foreach (GridInstantMessage im in msglist)
183 { 186 {
184 // client.SendInstantMessage(im); 187 // client.SendInstantMessage(im);
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index 4f03b0e..09552a8 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -417,7 +417,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
417 { 417 {
418 // Check if this is ours to handle 418 // Check if this is ours to handle
419 // 419 //
420 m_log.Info("OnFridInstantMessage"); 420 //m_log.Info("OnFridInstantMessage");
421 if (msg.dialog != (byte) InstantMessageDialog.InventoryOffered) 421 if (msg.dialog != (byte) InstantMessageDialog.InventoryOffered)
422 return; 422 return;
423 423
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index b1b2336f8..14bab6e 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -256,10 +256,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
256 // Fix ownership/creator of inventory items 256 // Fix ownership/creator of inventory items
257 // Not doing so results in inventory items 257 // Not doing so results in inventory items
258 // being no copy/no mod for everyone 258 // being no copy/no mod for everyone
259 lock (part.TaskInventory) 259 part.TaskInventory.LockItemsForRead(true);
260 TaskInventoryDictionary inv = part.TaskInventory;
261 foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv)
260 { 262 {
261 TaskInventoryDictionary inv = part.TaskInventory; 263 if (!ResolveUserUuid(kvp.Value.OwnerID))
262 foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv)
263 { 264 {
264 if (!ResolveUserUuid(kvp.Value.OwnerID)) 265 if (!ResolveUserUuid(kvp.Value.OwnerID))
265 { 266 {
@@ -271,6 +272,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
271 } 272 }
272 } 273 }
273 } 274 }
275 part.TaskInventory.LockItemsForRead(false);
274 } 276 }
275 277
276 if (m_scene.AddRestoredSceneObject(sceneObject, true, false)) 278 if (m_scene.AddRestoredSceneObject(sceneObject, true, false))
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index f0c87f4..ef3e722 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -81,6 +81,8 @@ namespace OpenSim.Region.CoreModules.World.Land
81 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; 81 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
82 82
83 private bool m_allowedForcefulBans = true; 83 private bool m_allowedForcefulBans = true;
84 private UUID DefaultGodParcelGroup;
85 private string DefaultGodParcelName;
84 86
85 // caches ExtendedLandData 87 // caches ExtendedLandData
86 private Cache parcelInfoCache; 88 private Cache parcelInfoCache;
@@ -94,6 +96,12 @@ namespace OpenSim.Region.CoreModules.World.Land
94 96
95 public void Initialise(IConfigSource source) 97 public void Initialise(IConfigSource source)
96 { 98 {
99 IConfig cnf = source.Configs["LandManagement"];
100 if (cnf != null)
101 {
102 DefaultGodParcelGroup = new UUID(cnf.GetString("DefaultAdministratorGroupUUID", UUID.Zero.ToString()));
103 DefaultGodParcelName = cnf.GetString("DefaultAdministratorParcelName", "Default Parcel");
104 }
97 } 105 }
98 106
99 public void AddRegion(Scene scene) 107 public void AddRegion(Scene scene)
@@ -153,6 +161,10 @@ namespace OpenSim.Region.CoreModules.World.Land
153 client.OnParcelInfoRequest += ClientOnParcelInfoRequest; 161 client.OnParcelInfoRequest += ClientOnParcelInfoRequest;
154 client.OnParcelDwellRequest += ClientOnParcelDwellRequest; 162 client.OnParcelDwellRequest += ClientOnParcelDwellRequest;
155 client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup; 163 client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup;
164 client.OnParcelGodMark += ClientOnParcelGodMark;
165 client.OnSimWideDeletes += ClientOnSimWideDeletes;
166 client.OnParcelFreezeUser += ClientOnParcelFreezeUser;
167 client.OnParcelEjectUser += ClientOnParcelEjectUser;
156 168
157 EntityBase presenceEntity; 169 EntityBase presenceEntity;
158 if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) 170 if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence)
@@ -261,20 +273,103 @@ namespace OpenSim.Region.CoreModules.World.Land
261 return parcelsNear; 273 return parcelsNear;
262 } 274 }
263 275
264 public void SendYouAreBannedNotice(ScenePresence avatar) 276
277 public void MoveUserOutOfParcel(ScenePresence avatar)
265 { 278 {
266 if (AllowedForcefulBans) 279 if (avatar.GodLevel == 0)
267 { 280 {
268 avatar.ControllingClient.SendAlertMessage( 281 ILandObject land = m_scene.LandChannel.GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
269 "You are not allowed on this parcel because you are banned. Please go away."); 282 List<ILandObject> parcelsNear = new List<ILandObject>();
270 283
271 avatar.PhysicsActor.Position = avatar.lastKnownAllowedPosition; 284 for (int x = -2; x <= 2; x += 2)
272 avatar.PhysicsActor.Velocity = Vector3.Zero; 285 {
273 } 286 ILandObject check = GetLandObject(avatar.AbsolutePosition.X + x, avatar.AbsolutePosition.Y);
274 else 287 if (check != null)
275 { 288 {
276 avatar.ControllingClient.SendAlertMessage( 289 if (check.IsEitherBannedOrRestricted(avatar.UUID) != true)
277 "You are not allowed on this parcel because you are banned; however, the grid administrator has disabled ban lines globally. Please obey the land owner's requests or you can be banned from the entire sim!"); 290 {
291 Vector3 target = new Vector3(avatar.AbsolutePosition.X + x, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z);
292 avatar.TeleportWithMomentum(target);
293 return;
294 }
295 }
296 }
297 for (int y = -2; y <= 2; y += 2)
298 {
299 ILandObject check = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y + y);
300 if (check != null)
301 {
302 if (check.IsEitherBannedOrRestricted(avatar.UUID) != true)
303 {
304 Vector3 target = new Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y + y, avatar.AbsolutePosition.Z);
305 avatar.TeleportWithMomentum(target);
306 return;
307 }
308 }
309 }
310 List<ILandObject> allParcels = new List<ILandObject>();
311 allParcels = AllParcels();
312 if (allParcels.Count != 1)
313 {
314 foreach (ILandObject parcel in allParcels)
315 {
316 if (parcel.IsEitherBannedOrRestricted(avatar.UUID) != true)
317 {
318 Vector3 temptarget = parcel.LandData.UserLocation;
319 if (parcel.ContainsPoint((int)parcel.LandData.UserLocation.X, (int)parcel.LandData.UserLocation.Y))
320 {
321 avatar.TeleportWithMomentum(temptarget);
322 return;
323 }
324 else
325 {
326 for (int x = 0; x <= Constants.RegionSize / 3; x += 3)
327 {
328 for (int y = 0; y <= Constants.RegionSize / 3; y += 3)
329 {
330 if (parcel.ContainsPoint(x, y))
331 {
332 temptarget = new Vector3(x, y, avatar.AbsolutePosition.Z);
333 avatar.TeleportWithMomentum(temptarget);
334 return;
335 }
336 }
337 }
338 }
339 }
340 }
341 }
342 //Move to region side
343 if (avatar.AbsolutePosition.X > avatar.AbsolutePosition.Y)
344 {
345 if (avatar.AbsolutePosition.X > .5 * Constants.RegionSize)
346 {
347 Vector3 target = new Vector3(Constants.RegionSize, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); ;
348 avatar.TeleportWithMomentum(target);
349 return;
350 }
351 else
352 {
353 Vector3 target = new Vector3(0, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); ;
354 avatar.TeleportWithMomentum(target);
355 return;
356 }
357 }
358 else
359 {
360 if (avatar.AbsolutePosition.Y > .5 * Constants.RegionSize)
361 {
362 Vector3 target = new Vector3(avatar.AbsolutePosition.X, Constants.RegionSize, avatar.AbsolutePosition.Z); ;
363 avatar.TeleportWithMomentum(target);
364 return;
365 }
366 else
367 {
368 Vector3 target = new Vector3(avatar.AbsolutePosition.X, 0, avatar.AbsolutePosition.Z); ;
369 avatar.TeleportWithMomentum(target);
370 return;
371 }
372 }
278 } 373 }
279 } 374 }
280 375
@@ -294,16 +389,7 @@ namespace OpenSim.Region.CoreModules.World.Land
294 { 389 {
295 if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID)) 390 if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID))
296 { 391 {
297 SendYouAreBannedNotice(avatar); 392 MoveUserOutOfParcel(avatar);
298 }
299 else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID))
300 {
301 avatar.ControllingClient.SendAlertMessage(
302 "You are not allowed on this parcel because the land owner has restricted access. For now, you can enter, but please respect the land owner's decisions (or he can ban you!).");
303 }
304 else
305 {
306 avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
307 } 393 }
308 } 394 }
309 else 395 else
@@ -314,28 +400,47 @@ namespace OpenSim.Region.CoreModules.World.Land
314 } 400 }
315 } 401 }
316 402
317 public void SendOutNearestBanLine(IClientAPI avatar) 403 public void SendOutNearestBanLine(ScenePresence avatar)
318 { 404 {
319 List<ScenePresence> avatars = m_scene.GetAvatars(); 405 ILandObject checkBan = null;
320 foreach (ScenePresence presence in avatars) 406 for (int x = -2; x <= 2; x += 2)
321 { 407 {
322 if (presence.UUID == avatar.AgentId) 408 checkBan = GetLandObject(avatar.AbsolutePosition.X + x, avatar.AbsolutePosition.Y);
409 if (checkBan != null)
323 { 410 {
324 List<ILandObject> checkLandParcels = ParcelsNearPoint(presence.AbsolutePosition); 411 if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT)
325 foreach (ILandObject checkBan in checkLandParcels)
326 { 412 {
327 if (checkBan.IsBannedFromLand(avatar.AgentId)) 413 if (checkBan.IsRestrictedFromLand(avatar.ControllingClient.AgentId))
328 { 414 {
329 checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionBanned, false, (int)ParcelResult.Single, avatar); 415 checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionNotOnAccessList, true, (int)ParcelResult.Multiple, avatar.ControllingClient);
330 return; //Only send one 416 return;
331 } 417 }
332 if (checkBan.IsRestrictedFromLand(avatar.AgentId)) 418 if (checkBan.IsBannedFromLand(avatar.ControllingClient.AgentId))
333 { 419 {
334 checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionNotOnAccessList, false, (int)ParcelResult.Single, avatar); 420 checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionBanned, true, (int)ParcelResult.Multiple, avatar.ControllingClient);
335 return; //Only send one 421 return;
422 }
423 }
424 }
425 }
426 for (int y = -2; y <= 2; y += 2)
427 {
428 checkBan = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y + y);
429 if (checkBan != null)
430 {
431 if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT)
432 {
433 if (checkBan.IsRestrictedFromLand(avatar.ControllingClient.AgentId))
434 {
435 checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionNotOnAccessList, true, (int)ParcelResult.Multiple, avatar.ControllingClient);
436 return;
437 }
438 if (checkBan.IsBannedFromLand(avatar.ControllingClient.AgentId))
439 {
440 checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionBanned, true, (int)ParcelResult.Multiple, avatar.ControllingClient);
441 return;
336 } 442 }
337 } 443 }
338 return;
339 } 444 }
340 } 445 }
341 } 446 }
@@ -382,25 +487,14 @@ namespace OpenSim.Region.CoreModules.World.Land
382 if (clientAvatar != null) 487 if (clientAvatar != null)
383 { 488 {
384 SendLandUpdate(clientAvatar); 489 SendLandUpdate(clientAvatar);
385 SendOutNearestBanLine(remote_client); 490 SendOutNearestBanLine(clientAvatar);
386 ILandObject parcel = GetLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y); 491 ILandObject parcel = GetLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y);
387 if (parcel != null) 492 if (parcel != null)
388 { 493 {
389 if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT && 494 if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT &&
390 clientAvatar.sentMessageAboutRestrictedParcelFlyingDown)
391 {
392 EventManagerOnAvatarEnteringNewParcel(clientAvatar, parcel.LandData.LocalID,
393 m_scene.RegionInfo.RegionID);
394 //They are going under the safety line!
395 if (!parcel.IsBannedFromLand(clientAvatar.UUID))
396 {
397 clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false;
398 }
399 }
400 else if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT &&
401 parcel.IsBannedFromLand(clientAvatar.UUID)) 495 parcel.IsBannedFromLand(clientAvatar.UUID))
402 { 496 {
403 SendYouAreBannedNotice(clientAvatar); 497 MoveUserOutOfParcel(clientAvatar);
404 } 498 }
405 } 499 }
406 } 500 }
@@ -448,9 +542,21 @@ namespace OpenSim.Region.CoreModules.World.Land
448 542
449 if (land != null) 543 if (land != null)
450 { 544 {
451 if (agentID == land.LandData.OwnerID) 545 if (m_scene.Permissions.CanEditParcel(agentID, land))
452 { 546 {
453 land.UpdateAccessList(flags, entries, remote_client); 547 land.UpdateAccessList(flags, entries, remote_client);
548 List<ScenePresence> presences = ((Scene)remote_client.Scene).GetAvatars();
549 foreach (ScenePresence presence in presences)
550 {
551 land = GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
552 if (land != null)
553 {
554 if (land.IsEitherBannedOrRestricted(presence.UUID))
555 {
556 MoveUserOutOfParcel(presence);
557 }
558 }
559 }
454 } 560 }
455 } 561 }
456 else 562 else
@@ -1016,7 +1122,25 @@ namespace OpenSim.Region.CoreModules.World.Land
1016 m_landList.TryGetValue(localID, out land); 1122 m_landList.TryGetValue(localID, out land);
1017 } 1123 }
1018 1124
1019 if (land != null) land.UpdateLandProperties(args, remote_client); 1125 if (land != null)
1126 {
1127 land.UpdateLandProperties(args, remote_client);
1128 if ((args.ParcelFlags & (uint)(ParcelFlags.UseBanList | ParcelFlags.UseAccessList | ParcelFlags.UseAccessGroup | ParcelFlags.UsePassList)) != 0)
1129 {
1130 List<ScenePresence> presences = ((Scene)remote_client.Scene).GetAvatars();
1131 foreach (ScenePresence presence in presences)
1132 {
1133 land = GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
1134 if (land != null)
1135 {
1136 if (land.IsEitherBannedOrRestricted(presence.UUID))
1137 {
1138 MoveUserOutOfParcel(presence);
1139 }
1140 }
1141 }
1142 }
1143 }
1020 } 1144 }
1021 1145
1022 public void ClientOnParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client) 1146 public void ClientOnParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client)
@@ -1428,5 +1552,319 @@ namespace OpenSim.Region.CoreModules.World.Land
1428 1552
1429 UpdateLandObject(localID, land.LandData); 1553 UpdateLandObject(localID, land.LandData);
1430 } 1554 }
1555 public void ClientOnParcelGodMark(IClientAPI client, UUID god, int landID)
1556 {
1557 ILandObject land = null;
1558 List<ILandObject> Land = ((Scene)client.Scene).LandChannel.AllParcels();
1559 foreach (ILandObject landObject in Land)
1560 {
1561 if (landObject.LandData.LocalID == landID)
1562 {
1563 land = landObject;
1564 }
1565 }
1566 land.DeedToGroup(DefaultGodParcelGroup);
1567 land.LandData.Name = DefaultGodParcelName;
1568 land.SendLandUpdateToAvatarsOverMe();
1569 }
1570 private void ClientOnSimWideDeletes(IClientAPI client, UUID agentID, int flags, UUID targetID)
1571 {
1572 ScenePresence SP;
1573 ((Scene)client.Scene).TryGetAvatar(client.AgentId, out SP);
1574 List<SceneObjectGroup> returns = new List<SceneObjectGroup>();
1575 if (SP.GodLevel != 0)
1576 {
1577 if (flags == 0) //All parcels, scripted or not
1578 {
1579 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1580 {
1581 if (e.OwnerID == targetID)
1582 {
1583 returns.Add(e);
1584 }
1585 }
1586 );
1587 }
1588 if (flags == 4) //All parcels, scripted object
1589 {
1590 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1591 {
1592 if (e.OwnerID == targetID)
1593 {
1594 if (e.scriptScore >= 0.01)
1595 {
1596 returns.Add(e);
1597 }
1598 }
1599 }
1600 );
1601 }
1602 if (flags == 4) //not target parcel, scripted object
1603 {
1604 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1605 {
1606 if (e.OwnerID == targetID)
1607 {
1608 ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y);
1609 if (landobject.LandData.OwnerID != e.OwnerID)
1610 {
1611 if (e.scriptScore >= 0.01)
1612 {
1613 returns.Add(e);
1614 }
1615 }
1616 }
1617 }
1618 );
1619 }
1620 foreach (SceneObjectGroup ol in returns)
1621 {
1622 ReturnObject(ol, client);
1623 }
1624 }
1625 }
1626 public void ReturnObject(SceneObjectGroup obj, IClientAPI client)
1627 {
1628 SceneObjectGroup[] objs = new SceneObjectGroup[1];
1629 objs[0] = obj;
1630 ((Scene)client.Scene).returnObjects(objs, client.AgentId);
1631 }
1632
1633 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
1634
1635 public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1636 {
1637 ScenePresence targetAvatar = null;
1638 ((Scene)client.Scene).TryGetAvatar(target, out targetAvatar);
1639 ScenePresence parcelManager = null;
1640 ((Scene)client.Scene).TryGetAvatar(client.AgentId, out parcelManager);
1641 System.Threading.Timer Timer;
1642
1643 if (targetAvatar.GodLevel == 0)
1644 {
1645 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1646 if (!((Scene)client.Scene).Permissions.CanEditParcel(client.AgentId, land))
1647 return;
1648 if (flags == 0)
1649 {
1650 targetAvatar.AllowMovement = false;
1651 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has frozen you for 30 seconds. You cannot move or interact with the world.");
1652 parcelManager.ControllingClient.SendAlertMessage("Avatar Frozen.");
1653 System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
1654 Timer = new System.Threading.Timer(timeCB, targetAvatar, 30000, 0);
1655 Timers.Add(targetAvatar.UUID, Timer);
1656 }
1657 else
1658 {
1659 targetAvatar.AllowMovement = true;
1660 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has unfrozen you.");
1661 parcelManager.ControllingClient.SendAlertMessage("Avatar Unfrozen.");
1662 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1663 Timers.Remove(targetAvatar.UUID);
1664 Timer.Dispose();
1665 }
1666 }
1667 }
1668 private void OnEndParcelFrozen(object avatar)
1669 {
1670 ScenePresence targetAvatar = (ScenePresence)avatar;
1671 targetAvatar.AllowMovement = true;
1672 System.Threading.Timer Timer;
1673 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1674 Timers.Remove(targetAvatar.UUID);
1675 targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false);
1676 }
1677
1678
1679 public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1680 {
1681 ScenePresence targetAvatar = null;
1682 ((Scene)client.Scene).TryGetAvatar(target, out targetAvatar);
1683 ScenePresence parcelManager = null;
1684 ((Scene)client.Scene).TryGetAvatar(client.AgentId, out parcelManager);
1685 //Just eject
1686 if (flags == 0)
1687 {
1688 if (targetAvatar.GodLevel == 0)
1689 {
1690 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1691 if (!((Scene)client.Scene).Permissions.CanEditParcel(client.AgentId, land))
1692 return;
1693
1694 Vector3 position = new Vector3(0, 0, 0);
1695 List<ILandObject> allParcels = new List<ILandObject>();
1696 allParcels = AllParcels();
1697 if (allParcels.Count != 1)
1698 {
1699 foreach (ILandObject parcel in allParcels)
1700 {
1701 if (parcel.LandData.GlobalID != land.LandData.GlobalID)
1702 {
1703 if (parcel.IsEitherBannedOrRestricted(targetAvatar.UUID) != true)
1704 {
1705 for (int x = 1; x <= Constants.RegionSize; x += 2)
1706 {
1707 for (int y = 1; y <= Constants.RegionSize; y += 2)
1708 {
1709 if (parcel.ContainsPoint(x, y))
1710 {
1711 position = new Vector3(x, y, targetAvatar.AbsolutePosition.Z);
1712 targetAvatar.TeleportWithMomentum(position);
1713 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1714 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1715 return;
1716 }
1717 }
1718 }
1719 }
1720 }
1721 }
1722 }
1723 Vector3 targetVector;
1724 if (targetAvatar.AbsolutePosition.X > targetAvatar.AbsolutePosition.Y)
1725 {
1726 if (targetAvatar.AbsolutePosition.X > .5 * Constants.RegionSize)
1727 {
1728 targetVector = new Vector3(Constants.RegionSize, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1729 targetAvatar.TeleportWithMomentum(targetVector);
1730 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1731 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1732 return;
1733 }
1734 else
1735 {
1736 targetVector = new Vector3(0, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1737 targetAvatar.TeleportWithMomentum(targetVector);
1738 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1739 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1740 return;
1741 }
1742 }
1743 else
1744 {
1745 if (targetAvatar.AbsolutePosition.Y > .5 * Constants.RegionSize)
1746 {
1747 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, Constants.RegionSize, targetAvatar.AbsolutePosition.Z); ;
1748 targetAvatar.TeleportWithMomentum(targetVector);
1749 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1750 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1751 return;
1752 }
1753 else
1754 {
1755 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, 0, targetAvatar.AbsolutePosition.Z); ;
1756 targetAvatar.TeleportWithMomentum(targetVector);
1757 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1758 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1759 return;
1760 }
1761 }
1762 }
1763 }
1764 //Eject and ban
1765 if (flags == 1)
1766 {
1767 if (targetAvatar.GodLevel == 0)
1768 {
1769 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1770 if (!((Scene)client.Scene).Permissions.CanEditParcel(client.AgentId, land))
1771 return;
1772
1773 Vector3 position = new Vector3(0, 0, 0);
1774 List<ILandObject> allParcels = new List<ILandObject>();
1775 allParcels = AllParcels();
1776 if (allParcels.Count != 1)
1777 {
1778 foreach (ILandObject parcel in allParcels)
1779 {
1780 if (parcel.LandData.GlobalID != land.LandData.GlobalID)
1781 {
1782 if (parcel.IsEitherBannedOrRestricted(targetAvatar.UUID) != true)
1783 {
1784 for (int x = 1; x <= Constants.RegionSize; x += 2)
1785 {
1786 for (int y = 1; y <= Constants.RegionSize; y += 2)
1787 {
1788 if (parcel.ContainsPoint(x, y))
1789 {
1790 position = new Vector3(x, y, targetAvatar.AbsolutePosition.Z);
1791 targetAvatar.TeleportWithMomentum(position);
1792 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1793 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1794 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1795 entry.AgentID = targetAvatar.UUID;
1796 entry.Flags = AccessList.Ban;
1797 entry.Time = new DateTime();
1798 land.LandData.ParcelAccessList.Add(entry);
1799 return;
1800 }
1801 }
1802 }
1803 }
1804 }
1805 }
1806 }
1807 Vector3 targetVector;
1808 if (targetAvatar.AbsolutePosition.X > targetAvatar.AbsolutePosition.Y)
1809 {
1810 if (targetAvatar.AbsolutePosition.X > .5 * Constants.RegionSize)
1811 {
1812 targetVector = new Vector3(Constants.RegionSize, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1813 targetAvatar.TeleportWithMomentum(targetVector);
1814 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1815 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1816 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1817 entry.AgentID = targetAvatar.UUID;
1818 entry.Flags = AccessList.Ban;
1819 entry.Time = new DateTime();
1820 land.LandData.ParcelAccessList.Add(entry);
1821 return;
1822 }
1823 else
1824 {
1825 targetVector = new Vector3(0, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1826 targetAvatar.TeleportWithMomentum(targetVector);
1827 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1828 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1829 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1830 entry.AgentID = targetAvatar.UUID;
1831 entry.Flags = AccessList.Ban;
1832 entry.Time = new DateTime();
1833 land.LandData.ParcelAccessList.Add(entry);
1834 return;
1835 }
1836 }
1837 else
1838 {
1839 if (targetAvatar.AbsolutePosition.Y > .5 * Constants.RegionSize)
1840 {
1841 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, Constants.RegionSize, targetAvatar.AbsolutePosition.Z); ;
1842 targetAvatar.TeleportWithMomentum(targetVector);
1843 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1844 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1845 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1846 entry.AgentID = targetAvatar.UUID;
1847 entry.Flags = AccessList.Ban;
1848 entry.Time = new DateTime();
1849 land.LandData.ParcelAccessList.Add(entry);
1850 return;
1851 }
1852 else
1853 {
1854 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, 0, targetAvatar.AbsolutePosition.Z); ;
1855 targetAvatar.TeleportWithMomentum(targetVector);
1856 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1857 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1858 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1859 entry.AgentID = targetAvatar.UUID;
1860 entry.Flags = AccessList.Ban;
1861 entry.Time = new DateTime();
1862 land.LandData.ParcelAccessList.Add(entry);
1863 return;
1864 }
1865 }
1866 }
1867 }
1868 }
1431 } 1869 }
1432} 1870}
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 1fa8630..1c65965 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -267,11 +267,7 @@ namespace OpenSim.Region.CoreModules.World.Land
267 267
268 public bool IsEitherBannedOrRestricted(UUID avatar) 268 public bool IsEitherBannedOrRestricted(UUID avatar)
269 { 269 {
270 if (IsBannedFromLand(avatar)) 270 if (IsRestrictedFromLand(avatar) || IsBannedFromLand(avatar))
271 {
272 return true;
273 }
274 else if (IsRestrictedFromLand(avatar))
275 { 271 {
276 return true; 272 return true;
277 } 273 }
@@ -280,7 +276,8 @@ namespace OpenSim.Region.CoreModules.World.Land
280 276
281 public bool IsBannedFromLand(UUID avatar) 277 public bool IsBannedFromLand(UUID avatar)
282 { 278 {
283 if ((LandData.Flags & (uint) ParcelFlags.UseBanList) > 0) 279 ScenePresence SP = m_scene.GetScenePresence(avatar);
280 if ((LandData.Flags & (uint)ParcelFlags.UseBanList) > 0)
284 { 281 {
285 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); 282 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
286 entry.AgentID = avatar; 283 entry.AgentID = avatar;
@@ -288,8 +285,22 @@ namespace OpenSim.Region.CoreModules.World.Land
288 entry.Time = new DateTime(); 285 entry.Time = new DateTime();
289 if (LandData.ParcelAccessList.Contains(entry)) 286 if (LandData.ParcelAccessList.Contains(entry))
290 { 287 {
291 //They are banned, so lets send them a notice about this parcel 288 if ((LandData.Flags & (uint)ParcelFlags.UseAccessGroup) > 0)
292 return true; 289 {
290 if (LandData.GroupID == SP.ControllingClient.ActiveGroupId)
291 {
292 return false;
293 }
294 else
295 {
296 //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel
297 return true;
298 }
299 }
300 else
301 {
302 return true;
303 }
293 } 304 }
294 } 305 }
295 return false; 306 return false;
@@ -297,7 +308,8 @@ namespace OpenSim.Region.CoreModules.World.Land
297 308
298 public bool IsRestrictedFromLand(UUID avatar) 309 public bool IsRestrictedFromLand(UUID avatar)
299 { 310 {
300 if ((LandData.Flags & (uint) ParcelFlags.UseAccessList) > 0) 311 ScenePresence SP = m_scene.GetScenePresence(avatar);
312 if ((LandData.Flags & (uint)ParcelFlags.UseAccessList) > 0)
301 { 313 {
302 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); 314 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
303 entry.AgentID = avatar; 315 entry.AgentID = avatar;
@@ -305,8 +317,22 @@ namespace OpenSim.Region.CoreModules.World.Land
305 entry.Time = new DateTime(); 317 entry.Time = new DateTime();
306 if (!LandData.ParcelAccessList.Contains(entry)) 318 if (!LandData.ParcelAccessList.Contains(entry))
307 { 319 {
308 //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel 320 if ((LandData.Flags & (uint)ParcelFlags.UseAccessGroup) > 0)
309 return true; 321 {
322 if (LandData.GroupID == SP.ControllingClient.ActiveGroupId)
323 {
324 return false;
325 }
326 else
327 {
328 //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel
329 return true;
330 }
331 }
332 else
333 {
334 return true;
335 }
310 } 336 }
311 } 337 }
312 return false; 338 return false;
diff --git a/OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs b/OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs
new file mode 100644
index 0000000..72b0b38
--- /dev/null
+++ b/OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs
@@ -0,0 +1,274 @@
1/*
2 * Copyright (c) Thomas Grimshaw and Magne Metaverse Research
3 *
4 * This module is not open source. All rights reserved.
5 * Unauthorised copying, distribution or public display is prohibited.
6 *
7 */
8
9using System;
10using System.Collections.Generic;
11using System.IO;
12using System.Reflection;
13using OpenMetaverse;
14using log4net;
15using Nini.Config;
16using OpenSim.Data;
17using OpenSim.Framework;
18using OpenSim.Region.CoreModules.Framework.InterfaceCommander;
19using OpenSim.Region.Framework.Interfaces;
20using OpenSim.Region.Framework.Scenes;
21
22
23namespace OpenSim.Region.CoreModules.World.Meta7Windlight
24{
25 public class Meta7WindlightModule : IRegionModule, ICommandableModule
26 {
27 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
28 private readonly Commander m_commander = new Commander("windlight");
29 private Scene m_scene;
30 private static bool m_enableWindlight;
31
32 #region ICommandableModule Members
33
34 public ICommander CommandInterface
35 {
36 get { return m_commander; }
37 }
38
39 #endregion
40
41 #region IRegionModule Members
42
43 public static bool EnableWindlight
44 {
45 get
46 {
47 return m_enableWindlight;
48 }
49 set
50 {
51 }
52 }
53
54 public void Initialise(Scene scene, IConfigSource config)
55 {
56 m_scene = scene;
57 m_scene.RegisterModuleInterface<IRegionModule>(this);
58 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
59
60 // ini file settings
61 try
62 {
63 m_enableWindlight = config.Configs["Meta7Windlight"].GetBoolean("enable_windlight", false);
64 }
65 catch (Exception)
66 {
67 m_log.Debug("[WINDLIGHT]: ini failure for enable_windlight - using default");
68 }
69
70 if (m_enableWindlight)
71 {
72 m_scene.EventManager.OnMakeRootAgent += EventManager_OnMakeRootAgent;
73 m_scene.EventManager.OnSaveNewWindlightProfile += EventManager_OnSaveNewWindlightProfile;
74 m_scene.EventManager.OnSendNewWindlightProfileTargeted += EventManager_OnSendNewWindlightProfileTargeted;
75 }
76
77 InstallCommands();
78
79 m_log.Debug("[WINDLIGHT]: Initialised windlight module");
80 }
81
82 private List<byte[]> compileWindlightSettings(RegionMeta7WindlightData wl)
83 {
84 byte[] mBlock = new Byte[249];
85 int pos = 0;
86
87 wl.waterColor.ToBytes(mBlock, 0); pos += 12;
88 Utils.FloatToBytes(wl.waterFogDensityExponent).CopyTo(mBlock, pos); pos += 4;
89 Utils.FloatToBytes(wl.underwaterFogModifier).CopyTo(mBlock, pos); pos += 4;
90 wl.reflectionWaveletScale.ToBytes(mBlock, pos); pos += 12;
91 Utils.FloatToBytes(wl.fresnelScale).CopyTo(mBlock, pos); pos += 4;
92 Utils.FloatToBytes(wl.fresnelOffset).CopyTo(mBlock, pos); pos += 4;
93 Utils.FloatToBytes(wl.refractScaleAbove).CopyTo(mBlock, pos); pos += 4;
94 Utils.FloatToBytes(wl.refractScaleBelow).CopyTo(mBlock, pos); pos += 4;
95 Utils.FloatToBytes(wl.blurMultiplier).CopyTo(mBlock, pos); pos += 4;
96 wl.bigWaveDirection.ToBytes(mBlock, pos); pos += 8;
97 wl.littleWaveDirection.ToBytes(mBlock, pos); pos += 8;
98 wl.normalMapTexture.ToBytes(mBlock, pos); pos += 16;
99 wl.horizon.ToBytes(mBlock, pos); pos += 16;
100 Utils.FloatToBytes(wl.hazeHorizon).CopyTo(mBlock, pos); pos += 4;
101 wl.blueDensity.ToBytes(mBlock, pos); pos += 16;
102 Utils.FloatToBytes(wl.hazeDensity).CopyTo(mBlock, pos); pos += 4;
103 Utils.FloatToBytes(wl.densityMultiplier).CopyTo(mBlock, pos); pos += 4;
104 Utils.FloatToBytes(wl.distanceMultiplier).CopyTo(mBlock, pos); pos += 4;
105 wl.sunMoonColor.ToBytes(mBlock, pos); pos += 16;
106 Utils.FloatToBytes(wl.sunMoonPosition).CopyTo(mBlock, pos); pos += 4;
107 wl.ambient.ToBytes(mBlock, pos); pos += 16;
108 Utils.FloatToBytes(wl.eastAngle).CopyTo(mBlock, pos); pos += 4;
109 Utils.FloatToBytes(wl.sunGlowFocus).CopyTo(mBlock, pos); pos += 4;
110 Utils.FloatToBytes(wl.sunGlowSize).CopyTo(mBlock, pos); pos += 4;
111 Utils.FloatToBytes(wl.sceneGamma).CopyTo(mBlock, pos); pos += 4;
112 Utils.FloatToBytes(wl.starBrightness).CopyTo(mBlock, pos); pos += 4;
113 wl.cloudColor.ToBytes(mBlock, pos); pos += 16;
114 wl.cloudXYDensity.ToBytes(mBlock, pos); pos += 12;
115 Utils.FloatToBytes(wl.cloudCoverage).CopyTo(mBlock, pos); pos += 4;
116 Utils.FloatToBytes(wl.cloudScale).CopyTo(mBlock, pos); pos += 4;
117 wl.cloudDetailXYDensity.ToBytes(mBlock, pos); pos += 12;
118 Utils.FloatToBytes(wl.cloudScrollX).CopyTo(mBlock, pos); pos += 4;
119 Utils.FloatToBytes(wl.cloudScrollY).CopyTo(mBlock, pos); pos += 4;
120 Utils.UInt16ToBytes(wl.maxAltitude).CopyTo(mBlock, pos); pos += 2;
121 mBlock[pos] = Convert.ToByte(wl.cloudScrollXLock); pos++;
122 mBlock[pos] = Convert.ToByte(wl.cloudScrollYLock); pos++;
123 mBlock[pos] = Convert.ToByte(wl.drawClassicClouds); pos++;
124 List<byte[]> param = new List<byte[]>();
125 param.Add(mBlock);
126 return param;
127 }
128 public void SendProfileToClient(ScenePresence presence)
129 {
130 IClientAPI client = presence.ControllingClient;
131 if (m_enableWindlight)
132 {
133 if (presence.IsChildAgent == false)
134 {
135 List<byte[]> param = compileWindlightSettings(m_scene.RegionInfo.WindlightSettings);
136 client.SendGenericMessage("Windlight", param);
137 }
138 }
139 else
140 {
141 //We probably don't want to spam chat with this.. probably
142 //m_log.Debug("[WINDLIGHT]: Module disabled");
143 }
144 }
145 public void SendProfileToClient(ScenePresence presence, RegionMeta7WindlightData wl)
146 {
147 IClientAPI client = presence.ControllingClient;
148 if (m_enableWindlight)
149 {
150 if (presence.IsChildAgent == false)
151 {
152 List<byte[]> param = compileWindlightSettings(wl);
153 client.SendGenericMessage("Windlight", param);
154 }
155 }
156 else
157 {
158 //We probably don't want to spam chat with this.. probably
159 //m_log.Debug("[WINDLIGHT]: Module disabled");
160 }
161 }
162 private void EventManager_OnMakeRootAgent(ScenePresence presence)
163 {
164 m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client");
165 SendProfileToClient(presence);
166 }
167 private void EventManager_OnSendNewWindlightProfileTargeted(RegionMeta7WindlightData wl, UUID pUUID)
168 {
169 ScenePresence Sc;
170 if (m_scene.TryGetAvatar(pUUID,out Sc))
171 {
172 SendProfileToClient(Sc,wl);
173 }
174 }
175 private void EventManager_OnSaveNewWindlightProfile()
176 {
177 m_scene.ForEachScenePresence(SendProfileToClient);
178 }
179
180 public void PostInitialise()
181 {
182
183 }
184
185 public void Close()
186 {
187 }
188
189 public string Name
190 {
191 get { return "Meta7WindlightModule"; }
192 }
193
194 public bool IsSharedModule
195 {
196 get { return false; }
197 }
198
199 #endregion
200
201 #region events
202
203 #endregion
204
205 #region ICommandableModule Members
206
207 private void InstallCommands()
208 {
209 Command wlload = new Command("load", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleLoad, "Load windlight profile from the database and broadcast");
210 Command wlenable = new Command("enable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleEnable, "Enable the windlight plugin");
211 Command wldisable = new Command("disable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleDisable, "Enable the windlight plugin");
212
213 m_commander.RegisterCommand("load", wlload);
214 m_commander.RegisterCommand("enable", wlenable);
215 m_commander.RegisterCommand("disable", wldisable);
216
217 m_scene.RegisterModuleCommander(m_commander);
218 }
219
220 private void HandleLoad(Object[] args)
221 {
222 if (!m_enableWindlight)
223 {
224 m_log.InfoFormat("[WINDLIGHT]: Cannot load windlight profile, module disabled. Use 'windlight enable' first.");
225 }
226 else
227 {
228 m_log.InfoFormat("[WINDLIGHT]: Loading Windlight profile from database");
229 m_scene.LoadWindlightProfile();
230 m_log.InfoFormat("[WINDLIGHT]: Load complete");
231 }
232 }
233
234 private void HandleDisable(Object[] args)
235 {
236 m_log.InfoFormat("[WINDLIGHT]: Plugin now disabled");
237 m_enableWindlight=false;
238 }
239
240 private void HandleEnable(Object[] args)
241 {
242 m_log.InfoFormat("[WINDLIGHT]: Plugin now enabled");
243 m_enableWindlight = true;
244 }
245
246 /// <summary>
247 /// Processes commandline input. Do not call directly.
248 /// </summary>
249 /// <param name="args">Commandline arguments</param>
250 private void EventManager_OnPluginConsole(string[] args)
251 {
252 if (args[0] == "windlight")
253 {
254 if (args.Length == 1)
255 {
256 m_commander.ProcessConsoleCommand("add", new string[0]);
257 return;
258 }
259
260 string[] tmpArgs = new string[args.Length - 2];
261 int i;
262 for (i = 2; i < args.Length; i++)
263 {
264 tmpArgs[i - 2] = args[i];
265 }
266
267 m_commander.ProcessConsoleCommand(args[1], tmpArgs);
268 }
269 }
270 #endregion
271
272 }
273}
274