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.cs324
-rw-r--r--OpenSim/Region/CoreModules/World/Meta7Windlight/Meta7WindlightModule.cs274
6 files changed, 690 insertions, 31 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 38f371a..e0cdb36 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -82,6 +82,8 @@ namespace OpenSim.Region.CoreModules.World.Land
82 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; 82 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
83 83
84 private bool m_allowedForcefulBans = true; 84 private bool m_allowedForcefulBans = true;
85 private UUID DefaultGodParcelGroup;
86 private string DefaultGodParcelName;
85 87
86 // caches ExtendedLandData 88 // caches ExtendedLandData
87 private Cache parcelInfoCache; 89 private Cache parcelInfoCache;
@@ -96,6 +98,12 @@ namespace OpenSim.Region.CoreModules.World.Land
96 98
97 public void Initialise(IConfigSource source) 99 public void Initialise(IConfigSource source)
98 { 100 {
101 IConfig cnf = source.Configs["LandManagement"];
102 if (cnf != null)
103 {
104 DefaultGodParcelGroup = new UUID(cnf.GetString("DefaultAdministratorGroupUUID", UUID.Zero.ToString()));
105 DefaultGodParcelName = cnf.GetString("DefaultAdministratorParcelName", "Default Parcel");
106 }
99 } 107 }
100 108
101 public void AddRegion(Scene scene) 109 public void AddRegion(Scene scene)
@@ -1507,5 +1515,321 @@ namespace OpenSim.Region.CoreModules.World.Land
1507 1515
1508 UpdateLandObject(localID, land.LandData); 1516 UpdateLandObject(localID, land.LandData);
1509 } 1517 }
1518
1519 public void ClientOnParcelGodMark(IClientAPI client, UUID god, int landID)
1520 {
1521 ILandObject land = null;
1522 List<ILandObject> Land = ((Scene)client.Scene).LandChannel.AllParcels();
1523 foreach (ILandObject landObject in Land)
1524 {
1525 if (landObject.LandData.LocalID == landID)
1526 {
1527 land = landObject;
1528 }
1529 }
1530 land.DeedToGroup(DefaultGodParcelGroup);
1531 land.LandData.Name = DefaultGodParcelName;
1532 land.SendLandUpdateToAvatarsOverMe();
1533 }
1534
1535 private void ClientOnSimWideDeletes(IClientAPI client, UUID agentID, int flags, UUID targetID)
1536 {
1537 ScenePresence SP;
1538 ((Scene)client.Scene).TryGetAvatar(client.AgentId, out SP);
1539 List<SceneObjectGroup> returns = new List<SceneObjectGroup>();
1540 if (SP.GodLevel != 0)
1541 {
1542 if (flags == 0) //All parcels, scripted or not
1543 {
1544 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1545 {
1546 if (e.OwnerID == targetID)
1547 {
1548 returns.Add(e);
1549 }
1550 }
1551 );
1552 }
1553 if (flags == 4) //All parcels, scripted object
1554 {
1555 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1556 {
1557 if (e.OwnerID == targetID)
1558 {
1559 if (e.scriptScore >= 0.01)
1560 {
1561 returns.Add(e);
1562 }
1563 }
1564 }
1565 );
1566 }
1567 if (flags == 4) //not target parcel, scripted object
1568 {
1569 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1570 {
1571 if (e.OwnerID == targetID)
1572 {
1573 ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y);
1574 if (landobject.LandData.OwnerID != e.OwnerID)
1575 {
1576 if (e.scriptScore >= 0.01)
1577 {
1578 returns.Add(e);
1579 }
1580 }
1581 }
1582 }
1583 );
1584 }
1585 foreach (SceneObjectGroup ol in returns)
1586 {
1587 ReturnObject(ol, client);
1588 }
1589 }
1590 }
1591 public void ReturnObject(SceneObjectGroup obj, IClientAPI client)
1592 {
1593 SceneObjectGroup[] objs = new SceneObjectGroup[1];
1594 objs[0] = obj;
1595 ((Scene)client.Scene).returnObjects(objs, client.AgentId);
1596 }
1597
1598 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
1599
1600 public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1601 {
1602 ScenePresence targetAvatar = null;
1603 ((Scene)client.Scene).TryGetAvatar(target, out targetAvatar);
1604 ScenePresence parcelManager = null;
1605 ((Scene)client.Scene).TryGetAvatar(client.AgentId, out parcelManager);
1606 System.Threading.Timer Timer;
1607
1608 if (targetAvatar.GodLevel == 0)
1609 {
1610 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1611 if (!((Scene)client.Scene).Permissions.CanEditParcel(client.AgentId, land))
1612 return;
1613 if (flags == 0)
1614 {
1615 targetAvatar.AllowMovement = false;
1616 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has frozen you for 30 seconds. You cannot move or interact with the world.");
1617 parcelManager.ControllingClient.SendAlertMessage("Avatar Frozen.");
1618 System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
1619 Timer = new System.Threading.Timer(timeCB, targetAvatar, 30000, 0);
1620 Timers.Add(targetAvatar.UUID, Timer);
1621 }
1622 else
1623 {
1624 targetAvatar.AllowMovement = true;
1625 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has unfrozen you.");
1626 parcelManager.ControllingClient.SendAlertMessage("Avatar Unfrozen.");
1627 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1628 Timers.Remove(targetAvatar.UUID);
1629 Timer.Dispose();
1630 }
1631 }
1632 }
1633 private void OnEndParcelFrozen(object avatar)
1634 {
1635 ScenePresence targetAvatar = (ScenePresence)avatar;
1636 targetAvatar.AllowMovement = true;
1637 System.Threading.Timer Timer;
1638 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1639 Timers.Remove(targetAvatar.UUID);
1640 targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false);
1641 }
1642
1643
1644 public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1645 {
1646 ScenePresence targetAvatar = null;
1647 ((Scene)client.Scene).TryGetAvatar(target, out targetAvatar);
1648 ScenePresence parcelManager = null;
1649 ((Scene)client.Scene).TryGetAvatar(client.AgentId, out parcelManager);
1650 //Just eject
1651 if (flags == 0)
1652 {
1653 if (targetAvatar.GodLevel == 0)
1654 {
1655 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1656 if (!((Scene)client.Scene).Permissions.CanEditParcel(client.AgentId, land))
1657 return;
1658
1659 Vector3 position = new Vector3(0, 0, 0);
1660 List<ILandObject> allParcels = new List<ILandObject>();
1661 allParcels = AllParcels();
1662 if (allParcels.Count != 1)
1663 {
1664 foreach (ILandObject parcel in allParcels)
1665 {
1666 if (parcel.LandData.GlobalID != land.LandData.GlobalID)
1667 {
1668 if (parcel.IsEitherBannedOrRestricted(targetAvatar.UUID) != true)
1669 {
1670 for (int x = 1; x <= Constants.RegionSize; x += 2)
1671 {
1672 for (int y = 1; y <= Constants.RegionSize; y += 2)
1673 {
1674 if (parcel.ContainsPoint(x, y))
1675 {
1676 position = new Vector3(x, y, targetAvatar.AbsolutePosition.Z);
1677 targetAvatar.TeleportWithMomentum(position);
1678 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1679 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1680 return;
1681 }
1682 }
1683 }
1684 }
1685 }
1686 }
1687 }
1688 Vector3 targetVector;
1689 if (targetAvatar.AbsolutePosition.X > targetAvatar.AbsolutePosition.Y)
1690 {
1691 if (targetAvatar.AbsolutePosition.X > .5 * Constants.RegionSize)
1692 {
1693 targetVector = new Vector3(Constants.RegionSize, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1694 targetAvatar.TeleportWithMomentum(targetVector);
1695 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1696 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1697 return;
1698 }
1699 else
1700 {
1701 targetVector = new Vector3(0, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1702 targetAvatar.TeleportWithMomentum(targetVector);
1703 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1704 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1705 return;
1706 }
1707 }
1708 else
1709 {
1710 if (targetAvatar.AbsolutePosition.Y > .5 * Constants.RegionSize)
1711 {
1712 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, Constants.RegionSize, targetAvatar.AbsolutePosition.Z); ;
1713 targetAvatar.TeleportWithMomentum(targetVector);
1714 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1715 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1716 return;
1717 }
1718 else
1719 {
1720 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, 0, targetAvatar.AbsolutePosition.Z); ;
1721 targetAvatar.TeleportWithMomentum(targetVector);
1722 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1723 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1724 return;
1725 }
1726 }
1727 }
1728 }
1729 //Eject and ban
1730 if (flags == 1)
1731 {
1732 if (targetAvatar.GodLevel == 0)
1733 {
1734 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1735 if (!((Scene)client.Scene).Permissions.CanEditParcel(client.AgentId, land))
1736 return;
1737
1738 Vector3 position = new Vector3(0, 0, 0);
1739 List<ILandObject> allParcels = new List<ILandObject>();
1740 allParcels = AllParcels();
1741 if (allParcels.Count != 1)
1742 {
1743 foreach (ILandObject parcel in allParcels)
1744 {
1745 if (parcel.LandData.GlobalID != land.LandData.GlobalID)
1746 {
1747 if (parcel.IsEitherBannedOrRestricted(targetAvatar.UUID) != true)
1748 {
1749 for (int x = 1; x <= Constants.RegionSize; x += 2)
1750 {
1751 for (int y = 1; y <= Constants.RegionSize; y += 2)
1752 {
1753 if (parcel.ContainsPoint(x, y))
1754 {
1755 position = new Vector3(x, y, targetAvatar.AbsolutePosition.Z);
1756 targetAvatar.TeleportWithMomentum(position);
1757 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1758 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1759 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1760 entry.AgentID = targetAvatar.UUID;
1761 entry.Flags = AccessList.Ban;
1762 entry.Time = new DateTime();
1763 land.LandData.ParcelAccessList.Add(entry);
1764 return;
1765 }
1766 }
1767 }
1768 }
1769 }
1770 }
1771 }
1772 Vector3 targetVector;
1773 if (targetAvatar.AbsolutePosition.X > targetAvatar.AbsolutePosition.Y)
1774 {
1775 if (targetAvatar.AbsolutePosition.X > .5 * Constants.RegionSize)
1776 {
1777 targetVector = new Vector3(Constants.RegionSize, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1778 targetAvatar.TeleportWithMomentum(targetVector);
1779 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1780 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1781 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1782 entry.AgentID = targetAvatar.UUID;
1783 entry.Flags = AccessList.Ban;
1784 entry.Time = new DateTime();
1785 land.LandData.ParcelAccessList.Add(entry);
1786 return;
1787 }
1788 else
1789 {
1790 targetVector = new Vector3(0, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1791 targetAvatar.TeleportWithMomentum(targetVector);
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 else
1803 {
1804 if (targetAvatar.AbsolutePosition.Y > .5 * Constants.RegionSize)
1805 {
1806 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, Constants.RegionSize, targetAvatar.AbsolutePosition.Z); ;
1807 targetAvatar.TeleportWithMomentum(targetVector);
1808 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1809 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1810 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1811 entry.AgentID = targetAvatar.UUID;
1812 entry.Flags = AccessList.Ban;
1813 entry.Time = new DateTime();
1814 land.LandData.ParcelAccessList.Add(entry);
1815 return;
1816 }
1817 else
1818 {
1819 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, 0, targetAvatar.AbsolutePosition.Z); ;
1820 targetAvatar.TeleportWithMomentum(targetVector);
1821 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1822 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1823 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1824 entry.AgentID = targetAvatar.UUID;
1825 entry.Flags = AccessList.Ban;
1826 entry.Time = new DateTime();
1827 land.LandData.ParcelAccessList.Add(entry);
1828 return;
1829 }
1830 }
1831 }
1832 }
1833 }
1510 } 1834 }
1511} 1835}
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