aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Application/OpenSim.cs6
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs16
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs123
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs150
-rw-r--r--OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs124
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs43
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs123
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs7
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs36
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScriptModule.cs12
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs10
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs56
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs19
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs31
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/TerrainChannel.cs60
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs99
-rw-r--r--OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs26
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs109
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs23
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs9
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs15
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs5
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs31
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs5
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs27
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs61
30 files changed, 970 insertions, 272 deletions
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index aad73a3..9fcd99c 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -503,7 +503,11 @@ namespace OpenSim
503 string currentCommand; 503 string currentCommand;
504 while ((currentCommand = readFile.ReadLine()) != null) 504 while ((currentCommand = readFile.ReadLine()) != null)
505 { 505 {
506 if (currentCommand != String.Empty) 506 currentCommand = currentCommand.Trim();
507 if (!(currentCommand == ""
508 || currentCommand.StartsWith(";")
509 || currentCommand.StartsWith("//")
510 || currentCommand.StartsWith("#")))
507 { 511 {
508 m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'"); 512 m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'");
509 m_console.RunCommand(currentCommand); 513 m_console.RunCommand(currentCommand);
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index 2154827..ac22c3f 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -124,15 +124,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
124 "Archiving", this, "save iar", 124 "Archiving", this, "save iar",
125 "save iar [-h|--home=<url>] [--noassets] <first> <last> <inventory path> <password> [<IAR path>] [-c|--creators] [-v|--verbose]", 125 "save iar [-h|--home=<url>] [--noassets] <first> <last> <inventory path> <password> [<IAR path>] [-c|--creators] [-v|--verbose]",
126 "Save user inventory archive (IAR).", 126 "Save user inventory archive (IAR).",
127 "<first> is the user's first name." + Environment.NewLine 127 "<first> is the user's first name.\n"
128 + "<last> is the user's last name." + Environment.NewLine 128 + "<last> is the user's last name.\n"
129 + "<inventory path> is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine 129 + "<inventory path> is the path inside the user's inventory for the folder/item to be saved.\n"
130 + "-h|--home=<url> adds the url of the profile service to the saved user information." + Environment.NewLine
131 + "-c|--creators preserves information about foreign creators." + Environment.NewLine
132 + "-v|--verbose extra debug messages." + Environment.NewLine
133 + "--noassets stops assets being saved to the IAR."
134 + "<IAR path> is the filesystem path at which to save the IAR." 130 + "<IAR path> is the filesystem path at which to save the IAR."
135 + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME), 131 + string.Format(" If this is not given then the filename {0} in the current directory is used.\n", DEFAULT_INV_BACKUP_FILENAME)
132 + "-h|--home=<url> adds the url of the profile service to the saved user information.\n"
133 + "-c|--creators preserves information about foreign creators.\n"
134 + "-v|--verbose extra debug messages.\n"
135 + "--noassets stops assets being saved to the IAR.",
136 HandleSaveInvConsoleCommand); 136 HandleSaveInvConsoleCommand);
137 137
138 m_aScene = scene; 138 m_aScene = scene;
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs
new file mode 100644
index 0000000..8077a7a
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs
@@ -0,0 +1,123 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.IO;
30using System.Reflection;
31
32using OpenSim.Framework;
33using OpenSim.Framework.Console;
34using OpenSim.Region.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Services.Interfaces;
38using OpenSim.Services.Connectors.Hypergrid;
39
40using OpenMetaverse;
41using OpenMetaverse.Packets;
42using log4net;
43using Nini.Config;
44
45namespace OpenSim.Region.CoreModules.Framework.UserManagement
46{
47 public class HGUserManagementModule : UserManagementModule, ISharedRegionModule, IUserManagement
48 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51
52 #region ISharedRegionModule
53
54 public new void Initialise(IConfigSource config)
55 {
56 string umanmod = config.Configs["Modules"].GetString("UserManagementModule", base.Name);
57 if (umanmod == Name)
58 {
59 m_Enabled = true;
60 RegisterConsoleCmds();
61 m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name);
62 }
63 }
64
65 public override string Name
66 {
67 get { return "HGUserManagementModule"; }
68 }
69
70 #endregion ISharedRegionModule
71
72 protected override void AddAdditionalUsers(UUID avatarID, string query, List<UserData> users)
73 {
74 string[] words = query.Split(new char[] { ' ' });
75
76 for (int i = 0; i < words.Length; i++)
77 {
78 if (words[i].Length < 3)
79 {
80 if (i != words.Length - 1)
81 Array.Copy(words, i + 1, words, i, words.Length - i - 1);
82 Array.Resize(ref words, words.Length - 1);
83 }
84 }
85
86 if (words.Length == 0 || words.Length > 2)
87 return;
88
89 if (words.Length == 2) // First.Last @foo.com, maybe?
90 {
91 bool found = false;
92 foreach (UserData d in m_UserCache.Values)
93 {
94 if (d.LastName.StartsWith("@") &&
95 (d.FirstName.ToLower().Equals(words[0].ToLower()) ||
96 d.LastName.ToLower().Equals(words[1].ToLower())))
97 {
98 users.Add(d);
99 found = true;
100 break;
101 }
102 }
103 if (!found) // This is it! Let's ask the other world
104 {
105 // TODO
106 //UserAgentServiceConnector uasConn = new UserAgentServiceConnector(words[0]);
107 //uasConn.GetUserInfo(...);
108 }
109 }
110 else
111 {
112 foreach (UserData d in m_UserCache.Values)
113 {
114 if (d.LastName.StartsWith("@") &&
115 (d.FirstName.ToLower().StartsWith(query.ToLower()) ||
116 d.LastName.ToLower().StartsWith(query.ToLower())))
117 users.Add(d);
118 }
119 }
120 }
121
122 }
123} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
index 554af14..23ef0fc 100644
--- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
@@ -38,12 +38,13 @@ using OpenSim.Services.Interfaces;
38using OpenSim.Services.Connectors.Hypergrid; 38using OpenSim.Services.Connectors.Hypergrid;
39 39
40using OpenMetaverse; 40using OpenMetaverse;
41using OpenMetaverse.Packets;
41using log4net; 42using log4net;
42using Nini.Config; 43using Nini.Config;
43 44
44namespace OpenSim.Region.CoreModules.Framework.UserManagement 45namespace OpenSim.Region.CoreModules.Framework.UserManagement
45{ 46{
46 class UserData 47 public class UserData
47 { 48 {
48 public UUID Id { get; set; } 49 public UUID Id { get; set; }
49 public string FirstName { get; set; } 50 public string FirstName { get; set; }
@@ -56,36 +57,23 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
56 { 57 {
57 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 58 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58 59
59 private List<Scene> m_Scenes = new List<Scene>(); 60 protected bool m_Enabled;
61 protected List<Scene> m_Scenes = new List<Scene>();
60 62
61 // The cache 63 // The cache
62 Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>(); 64 protected Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>();
63 65
64 #region ISharedRegionModule 66 #region ISharedRegionModule
65 67
66 public void Initialise(IConfigSource config) 68 public void Initialise(IConfigSource config)
67 { 69 {
68 //m_Enabled = config.Configs["Modules"].GetBoolean("LibraryModule", m_Enabled); 70 string umanmod = config.Configs["Modules"].GetString("UserManagementModule", Name);
69 //if (m_Enabled) 71 if (umanmod == Name)
70 //{ 72 {
71 // IConfig libConfig = config.Configs["LibraryService"]; 73 m_Enabled = true;
72 // if (libConfig != null) 74 RegisterConsoleCmds();
73 // { 75 m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name);
74 // string dllName = libConfig.GetString("LocalServiceModule", string.Empty); 76 }
75 // m_log.Debug("[LIBRARY MODULE]: Library service dll is " + dllName);
76 // if (dllName != string.Empty)
77 // {
78 // Object[] args = new Object[] { config };
79 // m_Library = ServerUtils.LoadPlugin<ILibraryService>(dllName, args);
80 // }
81 // }
82 //}
83 MainConsole.Instance.Commands.AddCommand("Users", true,
84 "show names",
85 "show names",
86 "Show the bindings between user UUIDs and user names",
87 String.Empty,
88 HandleShowUsers);
89 } 77 }
90 78
91 public bool IsSharedModule 79 public bool IsSharedModule
@@ -93,9 +81,9 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
93 get { return true; } 81 get { return true; }
94 } 82 }
95 83
96 public string Name 84 public virtual string Name
97 { 85 {
98 get { return "UserManagement Module"; } 86 get { return "BasicUserManagementModule"; }
99 } 87 }
100 88
101 public Type ReplaceableInterface 89 public Type ReplaceableInterface
@@ -105,17 +93,23 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
105 93
106 public void AddRegion(Scene scene) 94 public void AddRegion(Scene scene)
107 { 95 {
108 m_Scenes.Add(scene); 96 if (m_Enabled)
97 {
98 m_Scenes.Add(scene);
109 99
110 scene.RegisterModuleInterface<IUserManagement>(this); 100 scene.RegisterModuleInterface<IUserManagement>(this);
111 scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient); 101 scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient);
112 scene.EventManager.OnPrimsLoaded += new EventManager.PrimsLoaded(EventManager_OnPrimsLoaded); 102 scene.EventManager.OnPrimsLoaded += new EventManager.PrimsLoaded(EventManager_OnPrimsLoaded);
103 }
113 } 104 }
114 105
115 public void RemoveRegion(Scene scene) 106 public void RemoveRegion(Scene scene)
116 { 107 {
117 scene.UnregisterModuleInterface<IUserManagement>(this); 108 if (m_Enabled)
118 m_Scenes.Remove(scene); 109 {
110 scene.UnregisterModuleInterface<IUserManagement>(this);
111 m_Scenes.Remove(scene);
112 }
119 } 113 }
120 114
121 public void RegionLoaded(Scene s) 115 public void RegionLoaded(Scene s)
@@ -149,7 +143,15 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
149 143
150 void EventManager_OnNewClient(IClientAPI client) 144 void EventManager_OnNewClient(IClientAPI client)
151 { 145 {
146 client.OnConnectionClosed += new Action<IClientAPI>(HandleConnectionClosed);
152 client.OnNameFromUUIDRequest += new UUIDNameRequest(HandleUUIDNameRequest); 147 client.OnNameFromUUIDRequest += new UUIDNameRequest(HandleUUIDNameRequest);
148 client.OnAvatarPickerRequest += new AvatarPickerRequest(HandleAvatarPickerRequest);
149 }
150
151 void HandleConnectionClosed(IClientAPI client)
152 {
153 client.OnNameFromUUIDRequest -= new UUIDNameRequest(HandleUUIDNameRequest);
154 client.OnAvatarPickerRequest -= new AvatarPickerRequest(HandleAvatarPickerRequest);
153 } 155 }
154 156
155 void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client) 157 void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client)
@@ -170,6 +172,78 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
170 } 172 }
171 } 173 }
172 174
175 public void HandleAvatarPickerRequest(IClientAPI client, UUID avatarID, UUID RequestID, string query)
176 {
177 //EventManager.TriggerAvatarPickerRequest();
178
179 m_log.DebugFormat("[USER MANAGEMENT MODULE]: HandleAvatarPickerRequest for {0}", query);
180
181 List<UserAccount> accs = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, query);
182
183 List<UserData> users = new List<UserData>();
184 if (accs != null)
185 {
186 m_log.DebugFormat("[USER MANAGEMENT MODULE]: Found {0} users", accs.Count);
187 foreach (UserAccount acc in accs)
188 {
189 UserData ud = new UserData();
190 ud.FirstName = acc.FirstName;
191 ud.LastName = acc.LastName;
192 ud.Id = acc.PrincipalID;
193 users.Add(ud);
194 }
195 }
196
197 AddAdditionalUsers(avatarID, query, users);
198
199 AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply);
200 // TODO: don't create new blocks if recycling an old packet
201
202 AvatarPickerReplyPacket.DataBlock[] searchData =
203 new AvatarPickerReplyPacket.DataBlock[users.Count];
204 AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock();
205
206 agentData.AgentID = avatarID;
207 agentData.QueryID = RequestID;
208 replyPacket.AgentData = agentData;
209 //byte[] bytes = new byte[AvatarResponses.Count*32];
210
211 int i = 0;
212 foreach (UserData item in users)
213 {
214 UUID translatedIDtem = item.Id;
215 searchData[i] = new AvatarPickerReplyPacket.DataBlock();
216 searchData[i].AvatarID = translatedIDtem;
217 searchData[i].FirstName = Utils.StringToBytes((string)item.FirstName);
218 searchData[i].LastName = Utils.StringToBytes((string)item.LastName);
219 i++;
220 }
221 if (users.Count == 0)
222 {
223 searchData = new AvatarPickerReplyPacket.DataBlock[0];
224 }
225 replyPacket.Data = searchData;
226
227 AvatarPickerReplyAgentDataArgs agent_data = new AvatarPickerReplyAgentDataArgs();
228 agent_data.AgentID = replyPacket.AgentData.AgentID;
229 agent_data.QueryID = replyPacket.AgentData.QueryID;
230
231 List<AvatarPickerReplyDataArgs> data_args = new List<AvatarPickerReplyDataArgs>();
232 for (i = 0; i < replyPacket.Data.Length; i++)
233 {
234 AvatarPickerReplyDataArgs data_arg = new AvatarPickerReplyDataArgs();
235 data_arg.AvatarID = replyPacket.Data[i].AvatarID;
236 data_arg.FirstName = replyPacket.Data[i].FirstName;
237 data_arg.LastName = replyPacket.Data[i].LastName;
238 data_args.Add(data_arg);
239 }
240 client.SendAvatarPickerReply(agent_data, data_args);
241 }
242
243 protected virtual void AddAdditionalUsers(UUID avatarID, string query, List<UserData> users)
244 {
245 }
246
173 #endregion Event Handlers 247 #endregion Event Handlers
174 248
175 private void CacheCreators(SceneObjectGroup sog) 249 private void CacheCreators(SceneObjectGroup sog)
@@ -425,13 +499,23 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
425 499
426 #endregion IUserManagement 500 #endregion IUserManagement
427 501
502 protected void RegisterConsoleCmds()
503 {
504 MainConsole.Instance.Commands.AddCommand("Users", true,
505 "show names",
506 "show names",
507 "Show the bindings between user UUIDs and user names",
508 String.Empty,
509 HandleShowUsers);
510 }
511
428 private void HandleShowUsers(string module, string[] cmd) 512 private void HandleShowUsers(string module, string[] cmd)
429 { 513 {
430 lock (m_UserCache) 514 lock (m_UserCache)
431 { 515 {
432 if (m_UserCache.Count == 0) 516 if (m_UserCache.Count == 0)
433 { 517 {
434 MainConsole.Instance.Output("No users not found"); 518 MainConsole.Instance.Output("No users found");
435 return; 519 return;
436 } 520 }
437 521
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
index e22fd38..dc6efed 100644
--- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
+++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
@@ -9,6 +9,7 @@
9 9
10 <Extension path = "/OpenSim/RegionModules"> 10 <Extension path = "/OpenSim/RegionModules">
11 <RegionModule id="UserManagementModule" type="OpenSim.Region.CoreModules.Framework.UserManagement.UserManagementModule" /> 11 <RegionModule id="UserManagementModule" type="OpenSim.Region.CoreModules.Framework.UserManagement.UserManagementModule" />
12 <RegionModule id="HGUserManagementModule" type="OpenSim.Region.CoreModules.Framework.UserManagement.HGUserManagementModule" />
12 <RegionModule id="EntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule" /> 13 <RegionModule id="EntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule" />
13 <RegionModule id="HGEntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.HGEntityTransferModule" /> 14 <RegionModule id="HGEntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.HGEntityTransferModule" />
14 <RegionModule id="InventoryAccessModule" type="OpenSim.Region.CoreModules.Framework.InventoryAccess.BasicInventoryAccessModule" /> 15 <RegionModule id="InventoryAccessModule" type="OpenSim.Region.CoreModules.Framework.InventoryAccess.BasicInventoryAccessModule" />
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs
new file mode 100644
index 0000000..f0d21e6
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs
@@ -0,0 +1,124 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Linq;
31using System.Reflection;
32using Nini.Config;
33using log4net;
34using OpenSim.Framework;
35using OpenSim.Services.Interfaces;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes;
38using OpenMetaverse;
39
40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41
42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
43{
44 public class AuthorizationService : IAuthorizationService
45 {
46 private enum AccessFlags
47 {
48 None = 0, /* No restrictions */
49 DisallowResidents = 1, /* Only gods and managers*/
50 DisallowForeigners = 2, /* Only local people */
51 }
52
53 private static readonly ILog m_log =
54 LogManager.GetLogger(
55 MethodBase.GetCurrentMethod().DeclaringType);
56
57 private IUserManagement m_UserManagement;
58 private IGridService m_GridService;
59
60 private Scene m_Scene;
61 AccessFlags m_accessValue = AccessFlags.None;
62
63
64 public AuthorizationService(IConfig config, Scene scene)
65 {
66 m_Scene = scene;
67 m_UserManagement = scene.RequestModuleInterface<IUserManagement>();
68 m_GridService = scene.GridService;
69
70 if (config != null)
71 {
72 string accessStr = config.GetString("Region_" + scene.RegionInfo.RegionName.Replace(' ', '_'), String.Empty);
73 if (accessStr != string.Empty)
74 {
75 try
76 {
77 m_accessValue = (AccessFlags)Enum.Parse(typeof(AccessFlags), accessStr);
78 }
79 catch (ArgumentException)
80 {
81 m_log.WarnFormat("[AuthorizationService]: {0} is not a valid access flag", accessStr);
82 }
83 }
84 m_log.DebugFormat("[AuthorizationService]: Region {0} access restrictions: {1}", m_Scene.RegionInfo.RegionName, m_accessValue);
85 }
86
87 }
88
89 public bool IsAuthorizedForRegion(
90 string user, string firstName, string lastName, string regionID, out string message)
91 {
92 message = "authorized";
93
94 // This should not happen
95 if (m_Scene.RegionInfo.RegionID.ToString() != regionID)
96 {
97 m_log.WarnFormat("[AuthorizationService]: Service for region {0} received request to authorize for region {1}",
98 m_Scene.RegionInfo.RegionID, regionID);
99 return true;
100 }
101
102 if (m_accessValue == AccessFlags.None)
103 return true;
104
105 UUID userID = new UUID(user);
106 bool authorized = true;
107 if ((m_accessValue & AccessFlags.DisallowForeigners) == AccessFlags.DisallowForeigners)
108 {
109 authorized = m_UserManagement.IsLocalGridUser(userID);
110 if (!authorized)
111 message = "no foreigner users allowed in this region";
112 }
113 if (authorized && (m_accessValue & AccessFlags.DisallowResidents) == AccessFlags.DisallowResidents)
114 {
115 authorized = m_Scene.Permissions.IsGod(userID) | m_Scene.Permissions.IsAdministrator(userID);
116 if (!authorized)
117 message = "only Admins and Managers allowed in this region";
118 }
119
120 return authorized;
121 }
122
123 }
124} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs
index 18a7177..c982db6 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs
@@ -39,13 +39,15 @@ using OpenMetaverse;
39 39
40namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization 40namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
41{ 41{
42 public class LocalAuthorizationServicesConnector : ISharedRegionModule, IAuthorizationService 42 public class LocalAuthorizationServicesConnector : INonSharedRegionModule, IAuthorizationService
43 { 43 {
44 private static readonly ILog m_log = 44 private static readonly ILog m_log =
45 LogManager.GetLogger( 45 LogManager.GetLogger(
46 MethodBase.GetCurrentMethod().DeclaringType); 46 MethodBase.GetCurrentMethod().DeclaringType);
47 47
48 private IAuthorizationService m_AuthorizationService; 48 private IAuthorizationService m_AuthorizationService;
49 private Scene m_Scene;
50 private IConfig m_AuthorizationConfig;
49 51
50 private bool m_Enabled = false; 52 private bool m_Enabled = false;
51 53
@@ -69,33 +71,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
69 string name = moduleConfig.GetString("AuthorizationServices", string.Empty); 71 string name = moduleConfig.GetString("AuthorizationServices", string.Empty);
70 if (name == Name) 72 if (name == Name)
71 { 73 {
72 IConfig authorizationConfig = source.Configs["AuthorizationService"];
73 if (authorizationConfig == null)
74 {
75 m_log.Error("[AUTHORIZATION CONNECTOR]: AuthorizationService missing from OpenSim.ini");
76 return;
77 }
78
79 string serviceDll = authorizationConfig.GetString("LocalServiceModule",
80 String.Empty);
81
82 if (serviceDll == String.Empty)
83 {
84 m_log.Error("[AUTHORIZATION CONNECTOR]: No LocalServiceModule named in section AuthorizationService");
85 return;
86 }
87
88 Object[] args = new Object[] { source };
89 m_AuthorizationService =
90 ServerUtils.LoadPlugin<IAuthorizationService>(serviceDll,
91 args);
92
93 if (m_AuthorizationService == null)
94 {
95 m_log.Error("[AUTHORIZATION CONNECTOR]: Can't load authorization service");
96 return;
97 }
98 m_Enabled = true; 74 m_Enabled = true;
75 m_AuthorizationConfig = source.Configs["AuthorizationService"];
99 m_log.Info("[AUTHORIZATION CONNECTOR]: Local authorization connector enabled"); 76 m_log.Info("[AUTHORIZATION CONNECTOR]: Local authorization connector enabled");
100 } 77 }
101 } 78 }
@@ -115,6 +92,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
115 return; 92 return;
116 93
117 scene.RegisterModuleInterface<IAuthorizationService>(this); 94 scene.RegisterModuleInterface<IAuthorizationService>(this);
95 m_Scene = scene;
96
97 scene.EventManager.OnLoginsEnabled += new EventManager.LoginsEnabled(OnLoginsEnabled);
118 } 98 }
119 99
120 public void RemoveRegion(Scene scene) 100 public void RemoveRegion(Scene scene)
@@ -131,9 +111,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
131 scene.RegionInfo.RegionName); 111 scene.RegionInfo.RegionName);
132 } 112 }
133 113
114 private void OnLoginsEnabled(string regionName)
115 {
116 m_AuthorizationService = new AuthorizationService(m_AuthorizationConfig, m_Scene);
117 }
118
134 public bool IsAuthorizedForRegion( 119 public bool IsAuthorizedForRegion(
135 string userID, string firstName, string lastName, string regionID, out string message) 120 string userID, string firstName, string lastName, string regionID, out string message)
136 { 121 {
122 message = "";
123 if (!m_Enabled)
124 return true;
125
137 return m_AuthorizationService.IsAuthorizedForRegion(userID, firstName, lastName, regionID, out message); 126 return m_AuthorizationService.IsAuthorizedForRegion(userID, firstName, lastName, regionID, out message);
138 } 127 }
139 } 128 }
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 35f47d2..b95bda5 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -26,8 +26,10 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using System.IO; 31using System.IO;
32using System.Linq;
31using System.Reflection; 33using System.Reflection;
32using System.Security; 34using System.Security;
33using System.Timers; 35using System.Timers;
@@ -46,8 +48,6 @@ namespace OpenSim.Region.CoreModules.World.Estate
46 { 48 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 50
49 private delegate void LookupUUIDS(List<UUID> uuidLst);
50
51 private Timer m_regionChangeTimer = new Timer(); 51 private Timer m_regionChangeTimer = new Timer();
52 public Scene Scene { get; private set; } 52 public Scene Scene { get; private set; }
53 public IUserManagement UserManager { get; private set; } 53 public IUserManagement UserManager { get; private set; }
@@ -907,98 +907,77 @@ namespace OpenSim.Region.CoreModules.World.Estate
907 if (!Scene.Permissions.CanIssueEstateCommand(remoteClient.AgentId, false)) 907 if (!Scene.Permissions.CanIssueEstateCommand(remoteClient.AgentId, false))
908 return; 908 return;
909 909
910 Dictionary<uint, float> SceneData = new Dictionary<uint,float>(); 910 Dictionary<uint, float> sceneData = null;
911 List<UUID> uuidNameLookupList = new List<UUID>(); 911 List<UUID> uuidNameLookupList = new List<UUID>();
912 912
913 if (reportType == 1) 913 if (reportType == 1)
914 { 914 {
915 SceneData = Scene.PhysicsScene.GetTopColliders(); 915 sceneData = Scene.PhysicsScene.GetTopColliders();
916 } 916 }
917 else if (reportType == 0) 917 else if (reportType == 0)
918 { 918 {
919 SceneData = Scene.SceneGraph.GetTopScripts(); 919 IScriptModule scriptModule = Scene.RequestModuleInterface<IScriptModule>();
920
921 if (scriptModule != null)
922 sceneData = scriptModule.GetObjectScriptsExecutionTimes();
920 } 923 }
921 924
922 List<LandStatReportItem> SceneReport = new List<LandStatReportItem>(); 925 List<LandStatReportItem> SceneReport = new List<LandStatReportItem>();
923 lock (SceneData) 926 if (sceneData != null)
924 { 927 {
925 foreach (uint obj in SceneData.Keys) 928 var sortedSceneData
929 = sceneData.Select(
930 item => new { Measurement = item.Value, Part = Scene.GetSceneObjectPart(item.Key) });
931
932 sortedSceneData.OrderBy(item => item.Measurement);
933
934 int items = 0;
935
936 foreach (var entry in sortedSceneData)
926 { 937 {
927 SceneObjectPart prt = Scene.GetSceneObjectPart(obj); 938 // The object may have been deleted since we received the data.
928 if (prt != null) 939 if (entry.Part == null)
940 continue;
941
942 // Don't show scripts that haven't executed or where execution time is below one microsecond in
943 // order to produce a more readable report.
944 if (entry.Measurement < 0.001)
945 continue;
946
947 items++;
948 SceneObjectGroup so = entry.Part.ParentGroup;
949
950 LandStatReportItem lsri = new LandStatReportItem();
951 lsri.LocationX = so.AbsolutePosition.X;
952 lsri.LocationY = so.AbsolutePosition.Y;
953 lsri.LocationZ = so.AbsolutePosition.Z;
954 lsri.Score = entry.Measurement;
955 lsri.TaskID = so.UUID;
956 lsri.TaskLocalID = so.LocalId;
957 lsri.TaskName = entry.Part.Name;
958 lsri.OwnerName = UserManager.GetUserName(so.OwnerID);
959
960 if (filter.Length != 0)
929 { 961 {
930 SceneObjectGroup sog = prt.ParentGroup; 962 if ((lsri.OwnerName.Contains(filter) || lsri.TaskName.Contains(filter)))
931 LandStatReportItem lsri = new LandStatReportItem();
932 lsri.LocationX = sog.AbsolutePosition.X;
933 lsri.LocationY = sog.AbsolutePosition.Y;
934 lsri.LocationZ = sog.AbsolutePosition.Z;
935 lsri.Score = SceneData[obj];
936 lsri.TaskID = sog.UUID;
937 lsri.TaskLocalID = sog.LocalId;
938 lsri.TaskName = sog.GetPartName(obj);
939 lsri.OwnerName = "waiting";
940 lock (uuidNameLookupList)
941 uuidNameLookupList.Add(sog.OwnerID);
942
943 if (filter.Length != 0)
944 { 963 {
945 if ((lsri.OwnerName.Contains(filter) || lsri.TaskName.Contains(filter)))
946 {
947 }
948 else
949 {
950 continue;
951 }
952 } 964 }
953 965 else
954 SceneReport.Add(lsri); 966 {
967 continue;
968 }
955 } 969 }
970
971 SceneReport.Add(lsri);
972
973 if (items >= 100)
974 break;
956 } 975 }
957 } 976 }
958 977
959 remoteClient.SendLandStatReply(reportType, requestFlags, (uint)SceneReport.Count,SceneReport.ToArray()); 978 remoteClient.SendLandStatReply(reportType, requestFlags, (uint)SceneReport.Count,SceneReport.ToArray());
960
961 if (uuidNameLookupList.Count > 0)
962 LookupUUID(uuidNameLookupList);
963 } 979 }
964 980
965 private static void LookupUUIDSCompleted(IAsyncResult iar)
966 {
967 LookupUUIDS icon = (LookupUUIDS)iar.AsyncState;
968 icon.EndInvoke(iar);
969 }
970
971 private void LookupUUID(List<UUID> uuidLst)
972 {
973 LookupUUIDS d = LookupUUIDsAsync;
974
975 d.BeginInvoke(uuidLst,
976 LookupUUIDSCompleted,
977 d);
978 }
979
980 private void LookupUUIDsAsync(List<UUID> uuidLst)
981 {
982 UUID[] uuidarr;
983
984 lock (uuidLst)
985 {
986 uuidarr = uuidLst.ToArray();
987 }
988
989 for (int i = 0; i < uuidarr.Length; i++)
990 {
991 // string lookupname = Scene.CommsManager.UUIDNameRequestString(uuidarr[i]);
992
993 IUserManagement userManager = Scene.RequestModuleInterface<IUserManagement>();
994 if (userManager != null)
995 userManager.GetUserName(uuidarr[i]);
996
997 // we drop it. It gets cached though... so we're ready for the next request.
998 // diva commnent 11/21/2010: uh?!? wft?
999 // justincc comment 21/01/2011: A side effect of userManager.GetUserName() I presume.
1000 }
1001 }
1002 #endregion 981 #endregion
1003 982
1004 #region Outgoing Packets 983 #region Outgoing Packets
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 0f83d82..02ac091 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -1664,7 +1664,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1664 { 1664 {
1665 if (e.OwnerID == targetID) 1665 if (e.OwnerID == targetID)
1666 { 1666 {
1667 if (e.scriptScore >= 0.01) 1667 if (e.ContainsScripts())
1668 { 1668 {
1669 returns.Add(e); 1669 returns.Add(e);
1670 } 1670 }
@@ -1681,7 +1681,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1681 ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y); 1681 ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y);
1682 if (landobject.LandData.OwnerID != e.OwnerID) 1682 if (landobject.LandData.OwnerID != e.OwnerID)
1683 { 1683 {
1684 if (e.scriptScore >= 0.01) 1684 if (e.ContainsScripts())
1685 { 1685 {
1686 returns.Add(e); 1686 returns.Add(e);
1687 } 1687 }
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 4805ccb..c51e140 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -86,6 +86,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
86 private volatile bool m_tainted; 86 private volatile bool m_tainted;
87 private readonly Stack<LandUndoState> m_undo = new Stack<LandUndoState>(5); 87 private readonly Stack<LandUndoState> m_undo = new Stack<LandUndoState>(5);
88 88
89 private String m_InitialTerrain = "pinhead-island";
90
89 /// <summary> 91 /// <summary>
90 /// Human readable list of terrain file extensions that are supported. 92 /// Human readable list of terrain file extensions that are supported.
91 /// </summary> 93 /// </summary>
@@ -109,6 +111,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain
109 /// <param name="config">Config for the region</param> 111 /// <param name="config">Config for the region</param>
110 public void Initialise(IConfigSource config) 112 public void Initialise(IConfigSource config)
111 { 113 {
114 IConfig terrainConfig = config.Configs["Terrain"];
115 if (terrainConfig != null)
116 m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain);
112 } 117 }
113 118
114 public void AddRegion(Scene scene) 119 public void AddRegion(Scene scene)
@@ -120,7 +125,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
120 { 125 {
121 if (m_scene.Heightmap == null) 126 if (m_scene.Heightmap == null)
122 { 127 {
123 m_channel = new TerrainChannel(); 128 m_channel = new TerrainChannel(m_InitialTerrain);
124 m_scene.Heightmap = m_channel; 129 m_scene.Heightmap = m_channel;
125 m_revert = new TerrainChannel(); 130 m_revert = new TerrainChannel();
126 UpdateRevertMap(); 131 UpdateRevertMap();
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index f9384e9..3efb7dd 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -92,7 +92,23 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
92 return; 92 return;
93 } 93 }
94 94
95//m_log.DebugFormat("MAP NAME=({0})", mapName); 95 //m_log.DebugFormat("MAP NAME=({0})", mapName);
96
97 // Hack to get around the fact that ll V3 now drops the port from the
98 // map name. See https://jira.secondlife.com/browse/VWR-28570
99 //
100 // Caller, use this magic form instead:
101 // secondlife://http|!!mygrid.com|8002|Region+Name/128/128
102 // or url encode if possible.
103 // the hacks we do with this viewer...
104 //
105 string mapNameOrig = mapName;
106 if (mapName.Contains("|"))
107 mapName = mapName.Replace('|', ':');
108 if (mapName.Contains("+"))
109 mapName = mapName.Replace('+', ' ');
110 if (mapName.Contains("!"))
111 mapName = mapName.Replace('!', '/');
96 112
97 // try to fetch from GridServer 113 // try to fetch from GridServer
98 List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); 114 List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20);
@@ -114,7 +130,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
114 data.MapImageId = UUID.Zero; 130 data.MapImageId = UUID.Zero;
115 else 131 else
116 data.MapImageId = info.TerrainImage; 132 data.MapImageId = info.TerrainImage;
117 data.Name = info.RegionName; 133 // ugh! V2-3 is very sensitive about the result being
134 // exactly the same as the requested name
135 if (regionInfos.Count == 1)
136 data.Name = mapNameOrig;
137 else
138 data.Name = info.RegionName;
118 data.RegionFlags = 0; // TODO not used? 139 data.RegionFlags = 0; // TODO not used?
119 data.WaterHeight = 0; // not used 140 data.WaterHeight = 0; // not used
120 data.X = (ushort)(info.RegionLocX / Constants.RegionSize); 141 data.X = (ushort)(info.RegionLocX / Constants.RegionSize);
@@ -138,6 +159,17 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
138 // flags are agent flags sent from the viewer. 159 // flags are agent flags sent from the viewer.
139 // they have different values depending on different viewers, apparently 160 // they have different values depending on different viewers, apparently
140 remoteClient.SendMapBlock(blocks, flags); 161 remoteClient.SendMapBlock(blocks, flags);
162
163 // send extra user messages for V3
164 // because the UI is very confusing
165 // while we don't fix the hard-coded urls
166 if (flags == 2)
167 {
168 if (regionInfos.Count == 0)
169 remoteClient.SendAgentAlertMessage("No regions found with that name.", true);
170 else if (regionInfos.Count == 1)
171 remoteClient.SendAgentAlertMessage("Region found!", false);
172 }
141 } 173 }
142 174
143// private Scene GetClientScene(IClientAPI client) 175// private Scene GetClientScene(IClientAPI client)
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
index 2d6758b..ce66100 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic;
30using OpenMetaverse; 31using OpenMetaverse;
31 32
32namespace OpenSim.Region.Framework.Interfaces 33namespace OpenSim.Region.Framework.Interfaces
@@ -76,5 +77,14 @@ namespace OpenSim.Region.Framework.Interfaces
76 /// Starts the processing threads. 77 /// Starts the processing threads.
77 /// </summary> 78 /// </summary>
78 void StartProcessing(); 79 void StartProcessing();
80
81 /// <summary>
82 /// Get the execution times of all scripts in each object.
83 /// </summary>
84 /// <returns>
85 /// A dictionary where the key is the root object ID of a linkset
86 /// and the value is a representative execution time in milliseconds of all scripts in that linkset.
87 /// </returns>
88 Dictionary<uint, float> GetObjectScriptsExecutionTimes();
79 } 89 }
80} 90} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs
index d7fa316..bb4c788 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs
@@ -31,6 +31,7 @@ using OpenMetaverse;
31namespace OpenSim.Region.Framework.Interfaces 31namespace OpenSim.Region.Framework.Interfaces
32{ 32{
33 public delegate void ScriptCommand(UUID script, string id, string module, string command, string k); 33 public delegate void ScriptCommand(UUID script, string id, string module, string command, string k);
34 public delegate object ScriptInvocation(UUID script, object[] parms);
34 35
35 /// <summary> 36 /// <summary>
36 /// Interface for communication between OpenSim modules and in-world scripts 37 /// Interface for communication between OpenSim modules and in-world scripts
@@ -45,6 +46,15 @@ namespace OpenSim.Region.Framework.Interfaces
45 /// </summary> 46 /// </summary>
46 event ScriptCommand OnScriptCommand; 47 event ScriptCommand OnScriptCommand;
47 48
49 void RegisterScriptInvocation(string name, ScriptInvocation fn, Type[] csig, Type rsig);
50
51 ScriptInvocation LookupScriptInvocation(string fname);
52 string LookupModInvocation(string fname);
53 Type[] LookupTypeSignature(string fname);
54 Type LookupReturnType(string fname);
55
56 object InvokeOperation(UUID scriptId, string fname, params object[] parms);
57
48 /// <summary> 58 /// <summary>
49 /// Send a link_message event to an in-world script 59 /// Send a link_message event to an in-world script
50 /// </summary> 60 /// </summary>
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index b006045..35ac908 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -341,62 +341,6 @@ namespace OpenSim.Region.Framework.Scenes
341 EventManager.TriggerObjectDeGrab(obj.RootPart.LocalId, part.LocalId, remoteClient, surfaceArg); 341 EventManager.TriggerObjectDeGrab(obj.RootPart.LocalId, part.LocalId, remoteClient, surfaceArg);
342 } 342 }
343 343
344 public void ProcessAvatarPickerRequest(IClientAPI client, UUID avatarID, UUID RequestID, string query)
345 {
346 //EventManager.TriggerAvatarPickerRequest();
347
348 List<UserAccount> accounts = UserAccountService.GetUserAccounts(RegionInfo.ScopeID, query);
349
350 if (accounts == null)
351 {
352 m_log.DebugFormat("[LLCIENT]: ProcessAvatarPickerRequest: returned null result");
353 return;
354 }
355
356 AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket) PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply);
357 // TODO: don't create new blocks if recycling an old packet
358
359 AvatarPickerReplyPacket.DataBlock[] searchData =
360 new AvatarPickerReplyPacket.DataBlock[accounts.Count];
361 AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock();
362
363 agentData.AgentID = avatarID;
364 agentData.QueryID = RequestID;
365 replyPacket.AgentData = agentData;
366 //byte[] bytes = new byte[AvatarResponses.Count*32];
367
368 int i = 0;
369 foreach (UserAccount item in accounts)
370 {
371 UUID translatedIDtem = item.PrincipalID;
372 searchData[i] = new AvatarPickerReplyPacket.DataBlock();
373 searchData[i].AvatarID = translatedIDtem;
374 searchData[i].FirstName = Utils.StringToBytes((string) item.FirstName);
375 searchData[i].LastName = Utils.StringToBytes((string) item.LastName);
376 i++;
377 }
378 if (accounts.Count == 0)
379 {
380 searchData = new AvatarPickerReplyPacket.DataBlock[0];
381 }
382 replyPacket.Data = searchData;
383
384 AvatarPickerReplyAgentDataArgs agent_data = new AvatarPickerReplyAgentDataArgs();
385 agent_data.AgentID = replyPacket.AgentData.AgentID;
386 agent_data.QueryID = replyPacket.AgentData.QueryID;
387
388 List<AvatarPickerReplyDataArgs> data_args = new List<AvatarPickerReplyDataArgs>();
389 for (i = 0; i < replyPacket.Data.Length; i++)
390 {
391 AvatarPickerReplyDataArgs data_arg = new AvatarPickerReplyDataArgs();
392 data_arg.AvatarID = replyPacket.Data[i].AvatarID;
393 data_arg.FirstName = replyPacket.Data[i].FirstName;
394 data_arg.LastName = replyPacket.Data[i].LastName;
395 data_args.Add(data_arg);
396 }
397 client.SendAvatarPickerReply(agent_data, data_args);
398 }
399
400 public void ProcessScriptReset(IClientAPI remoteClient, UUID objectID, 344 public void ProcessScriptReset(IClientAPI remoteClient, UUID objectID,
401 UUID itemID) 345 UUID itemID)
402 { 346 {
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index de1517b..753effc 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1632,8 +1632,15 @@ namespace OpenSim.Region.Framework.Scenes
1632 double[,] map = SimulationDataService.LoadTerrain(RegionInfo.RegionID); 1632 double[,] map = SimulationDataService.LoadTerrain(RegionInfo.RegionID);
1633 if (map == null) 1633 if (map == null)
1634 { 1634 {
1635 m_log.Info("[TERRAIN]: No default terrain. Generating a new terrain."); 1635 // This should be in the Terrain module, but it isn't because
1636 Heightmap = new TerrainChannel(); 1636 // the heightmap is needed _way_ before the modules are initialized...
1637 IConfig terrainConfig = m_config.Configs["Terrain"];
1638 String m_InitialTerrain = "pinhead-island";
1639 if (terrainConfig != null)
1640 m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain);
1641
1642 m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain);
1643 Heightmap = new TerrainChannel(m_InitialTerrain);
1637 1644
1638 SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); 1645 SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID);
1639 } 1646 }
@@ -2894,7 +2901,6 @@ namespace OpenSim.Region.Framework.Scenes
2894 { 2901 {
2895 //client.OnNameFromUUIDRequest += HandleUUIDNameRequest; 2902 //client.OnNameFromUUIDRequest += HandleUUIDNameRequest;
2896 client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; 2903 client.OnMoneyTransferRequest += ProcessMoneyTransferRequest;
2897 client.OnAvatarPickerRequest += ProcessAvatarPickerRequest;
2898 client.OnSetStartLocationRequest += SetHomeRezPoint; 2904 client.OnSetStartLocationRequest += SetHomeRezPoint;
2899 client.OnRegionHandleRequest += RegionHandleRequest; 2905 client.OnRegionHandleRequest += RegionHandleRequest;
2900 } 2906 }
@@ -3022,7 +3028,6 @@ namespace OpenSim.Region.Framework.Scenes
3022 { 3028 {
3023 //client.OnNameFromUUIDRequest -= HandleUUIDNameRequest; 3029 //client.OnNameFromUUIDRequest -= HandleUUIDNameRequest;
3024 client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest; 3030 client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest;
3025 client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest;
3026 client.OnSetStartLocationRequest -= SetHomeRezPoint; 3031 client.OnSetStartLocationRequest -= SetHomeRezPoint;
3027 client.OnRegionHandleRequest -= RegionHandleRequest; 3032 client.OnRegionHandleRequest -= RegionHandleRequest;
3028 } 3033 }
@@ -3693,9 +3698,9 @@ namespace OpenSim.Region.Framework.Scenes
3693 if (!AuthorizationService.IsAuthorizedForRegion( 3698 if (!AuthorizationService.IsAuthorizedForRegion(
3694 agent.AgentID.ToString(), agent.firstname, agent.lastname, RegionInfo.RegionID.ToString(), out reason)) 3699 agent.AgentID.ToString(), agent.firstname, agent.lastname, RegionInfo.RegionID.ToString(), out reason))
3695 { 3700 {
3696 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3701 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because {4}",
3697 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3702 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName, reason);
3698 3703
3699 return false; 3704 return false;
3700 } 3705 }
3701 } 3706 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 4e9a8f8..18069af 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -814,6 +814,7 @@ namespace OpenSim.Region.Framework.Scenes
814 #endregion 814 #endregion
815 815
816 #region Get Methods 816 #region Get Methods
817
817 /// <summary> 818 /// <summary>
818 /// Get the controlling client for the given avatar, if there is one. 819 /// Get the controlling client for the given avatar, if there is one.
819 /// 820 ///
@@ -1155,36 +1156,6 @@ namespace OpenSim.Region.Framework.Scenes
1155 return Entities.GetEntities(); 1156 return Entities.GetEntities();
1156 } 1157 }
1157 1158
1158 public Dictionary<uint, float> GetTopScripts()
1159 {
1160 Dictionary<uint, float> topScripts = new Dictionary<uint, float>();
1161
1162 EntityBase[] EntityList = GetEntities();
1163 int limit = 0;
1164 foreach (EntityBase ent in EntityList)
1165 {
1166 if (ent is SceneObjectGroup)
1167 {
1168 SceneObjectGroup grp = (SceneObjectGroup)ent;
1169 if ((grp.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0)
1170 {
1171 if (grp.scriptScore >= 0.01)
1172 {
1173 topScripts.Add(grp.LocalId, grp.scriptScore);
1174 limit++;
1175 if (limit >= 100)
1176 {
1177 break;
1178 }
1179 }
1180 grp.scriptScore = 0;
1181 }
1182 }
1183 }
1184
1185 return topScripts;
1186 }
1187
1188 #endregion 1159 #endregion
1189 1160
1190 #region Other Methods 1161 #region Other Methods
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 5507aa0..0d1adcb 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -293,8 +293,6 @@ namespace OpenSim.Region.Framework.Scenes
293 get { return RootPart.VolumeDetectActive; } 293 get { return RootPart.VolumeDetectActive; }
294 } 294 }
295 295
296 public float scriptScore;
297
298 private Vector3 lastPhysGroupPos; 296 private Vector3 lastPhysGroupPos;
299 private Quaternion lastPhysGroupRot; 297 private Quaternion lastPhysGroupRot;
300 298
@@ -1622,12 +1620,7 @@ namespace OpenSim.Region.Framework.Scenes
1622 1620
1623 public void AddScriptLPS(int count) 1621 public void AddScriptLPS(int count)
1624 { 1622 {
1625 if (scriptScore + count >= float.MaxValue - count) 1623 m_scene.SceneGraph.AddToScriptLPS(count);
1626 scriptScore = 0;
1627
1628 scriptScore += (float)count;
1629 SceneGraph d = m_scene.SceneGraph;
1630 d.AddToScriptLPS(count);
1631 } 1624 }
1632 1625
1633 public void AddActiveScriptCount(int count) 1626 public void AddActiveScriptCount(int count)
diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs
index ca6210d..c0ca48e 100644
--- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs
+++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs
@@ -46,23 +46,20 @@ namespace OpenSim.Region.Framework.Scenes
46 public TerrainChannel() 46 public TerrainChannel()
47 { 47 {
48 map = new double[Constants.RegionSize, Constants.RegionSize]; 48 map = new double[Constants.RegionSize, Constants.RegionSize];
49 taint = new bool[Constants.RegionSize / 16,Constants.RegionSize / 16]; 49 taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16];
50 50
51 int x; 51 PinHeadIsland();
52 for (x = 0; x < Constants.RegionSize; x++) 52 }
53 { 53
54 int y; 54 public TerrainChannel(String type)
55 for (y = 0; y < Constants.RegionSize; y++) 55 {
56 { 56 map = new double[Constants.RegionSize, Constants.RegionSize];
57 map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10; 57 taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16];
58 double spherFacA = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 50) * 0.01; 58
59 double spherFacB = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 100) * 0.001; 59 if (type.Equals("flat"))
60 if (map[x, y] < spherFacA) 60 FlatLand();
61 map[x, y] = spherFacA; 61 else
62 if (map[x, y] < spherFacB) 62 PinHeadIsland();
63 map[x, y] = spherFacB;
64 }
65 }
66 } 63 }
67 64
68 public TerrainChannel(double[,] import) 65 public TerrainChannel(double[,] import)
@@ -238,5 +235,36 @@ namespace OpenSim.Region.Framework.Scenes
238 } 235 }
239 } 236 }
240 } 237 }
238
239 private void PinHeadIsland()
240 {
241 int x;
242 for (x = 0; x < Constants.RegionSize; x++)
243 {
244 int y;
245 for (y = 0; y < Constants.RegionSize; y++)
246 {
247 map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10;
248 double spherFacA = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 50) * 0.01;
249 double spherFacB = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 100) * 0.001;
250 if (map[x, y] < spherFacA)
251 map[x, y] = spherFacA;
252 if (map[x, y] < spherFacB)
253 map[x, y] = spherFacB;
254 }
255 }
256 }
257
258 private void FlatLand()
259 {
260 int x;
261 for (x = 0; x < Constants.RegionSize; x++)
262 {
263 int y;
264 for (y = 0; y < Constants.RegionSize; y++)
265 map[x, y] = 21;
266 }
267 }
268
241 } 269 }
242} 270}
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index 44c9ada..a90362e 100644
--- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using System.Collections.Generic;
30using Nini.Config; 31using Nini.Config;
31using log4net; 32using log4net;
32using OpenSim.Framework; 33using OpenSim.Framework;
@@ -35,7 +36,7 @@ using OpenSim.Region.Framework.Scenes;
35using Mono.Addins; 36using Mono.Addins;
36using OpenMetaverse; 37using OpenMetaverse;
37 38
38namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms 39namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms
39{ 40{
40 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")] 41 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")]
41 class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms 42 class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms
@@ -43,10 +44,30 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
43 private static readonly ILog m_log = 44 private static readonly ILog m_log =
44 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 46
46 private IScriptModule m_scriptModule = null; 47#region ScriptInvocation
48 protected class ScriptInvocationData
49 {
50 public ScriptInvocation ScriptInvocationFn { get; private set; }
51 public string FunctionName { get; private set; }
52 public Type[] TypeSignature { get; private set; }
53 public Type ReturnType { get; private set; }
54
55 public ScriptInvocationData(string fname, ScriptInvocation fn, Type[] callsig, Type returnsig)
56 {
57 FunctionName = fname;
58 ScriptInvocationFn = fn;
59 TypeSignature = callsig;
60 ReturnType = returnsig;
61 }
62 }
47 63
64 private Dictionary<string,ScriptInvocationData> m_scriptInvocation = new Dictionary<string,ScriptInvocationData>();
65#endregion
66
67 private IScriptModule m_scriptModule = null;
48 public event ScriptCommand OnScriptCommand; 68 public event ScriptCommand OnScriptCommand;
49 69
70#region RegionModuleInterface
50 public void Initialise(IConfigSource config) 71 public void Initialise(IConfigSource config)
51 { 72 {
52 } 73 }
@@ -81,6 +102,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
81 public void Close() 102 public void Close()
82 { 103 {
83 } 104 }
105#endregion
106
107#region ScriptModuleComms
84 108
85 public void RaiseEvent(UUID script, string id, string module, string command, string k) 109 public void RaiseEvent(UUID script, string id, string module, string command, string k)
86 { 110 {
@@ -101,5 +125,76 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
101 125
102 m_scriptModule.PostScriptEvent(script, "link_message", args); 126 m_scriptModule.PostScriptEvent(script, "link_message", args);
103 } 127 }
128
129 public void RegisterScriptInvocation(string fname, ScriptInvocation fcall, Type[] csig, Type rsig)
130 {
131 lock (m_scriptInvocation)
132 {
133 m_scriptInvocation[fname] = new ScriptInvocationData(fname,fcall,csig,rsig);
134 }
135 }
136
137 public string LookupModInvocation(string fname)
138 {
139 lock (m_scriptInvocation)
140 {
141 ScriptInvocationData sid;
142 if (m_scriptInvocation.TryGetValue(fname,out sid))
143 {
144 if (sid.ReturnType == typeof(string))
145 return "modInvokeS";
146 else if (sid.ReturnType == typeof(int))
147 return "modInvokeI";
148 else if (sid.ReturnType == typeof(float))
149 return "modInvokeF";
150 }
151 }
152
153 return null;
154 }
155
156 public ScriptInvocation LookupScriptInvocation(string fname)
157 {
158 lock (m_scriptInvocation)
159 {
160 ScriptInvocationData sid;
161 if (m_scriptInvocation.TryGetValue(fname,out sid))
162 return sid.ScriptInvocationFn;
163 }
164
165 return null;
166 }
167
168 public Type[] LookupTypeSignature(string fname)
169 {
170 lock (m_scriptInvocation)
171 {
172 ScriptInvocationData sid;
173 if (m_scriptInvocation.TryGetValue(fname,out sid))
174 return sid.TypeSignature;
175 }
176
177 return null;
178 }
179
180 public Type LookupReturnType(string fname)
181 {
182 lock (m_scriptInvocation)
183 {
184 ScriptInvocationData sid;
185 if (m_scriptInvocation.TryGetValue(fname,out sid))
186 return sid.ReturnType;
187 }
188
189 return null;
190 }
191
192 public object InvokeOperation(UUID scriptid, string fname, params object[] parms)
193 {
194 ScriptInvocation fn = LookupScriptInvocation(fname);
195 return fn(scriptid,parms);
196 }
197#endregion
198
104 } 199 }
105} 200}
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
index 8762642..b04f6b6 100644
--- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
@@ -78,12 +78,38 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
78 /// </summary> 78 /// </summary>
79 string State { get; set; } 79 string State { get; set; }
80 80
81 /// <summary>
82 /// Time the script was last started
83 /// </summary>
84 DateTime TimeStarted { get; }
85
86 /// <summary>
87 /// Tick the last measurement period was started.
88 /// </summary>
89 long MeasurementPeriodTickStart { get; }
90
91 /// <summary>
92 /// Ticks spent executing in the last measurement period.
93 /// </summary>
94 long MeasurementPeriodExecutionTime { get; }
95
81 IScriptEngine Engine { get; } 96 IScriptEngine Engine { get; }
82 UUID AppDomain { get; set; } 97 UUID AppDomain { get; set; }
83 string PrimName { get; } 98 string PrimName { get; }
84 string ScriptName { get; } 99 string ScriptName { get; }
85 UUID ItemID { get; } 100 UUID ItemID { get; }
86 UUID ObjectID { get; } 101 UUID ObjectID { get; }
102
103 /// <summary>
104 /// UUID of the root object for the linkset that the script is in.
105 /// </summary>
106 UUID RootObjectID { get; }
107
108 /// <summary>
109 /// Local id of the root object for the linkset that the script is in.
110 /// </summary>
111 uint RootLocalID { get; }
112
87 uint LocalID { get; } 113 uint LocalID { get; }
88 UUID AssetID { get; } 114 UUID AssetID { get; }
89 Queue EventQueue { get; } 115 Queue EventQueue { get; }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
index d4facdd..2942104 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
@@ -116,6 +116,115 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
116 wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); 116 wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
117 } 117 }
118 118
119 /// <summary>
120 ///
121 /// </summary>
122 /// <param name="fname">The name of the function to invoke</param>
123 /// <param name="fname">List of parameters</param>
124 /// <returns>string result of the invocation</returns>
125 public string modInvokeS(string fname, params object[] parms)
126 {
127 Type returntype = m_comms.LookupReturnType(fname);
128 if (returntype != typeof(string))
129 MODError(String.Format("return type mismatch for {0}",fname));
130
131 return (string)modInvoke(fname,parms);
132 }
133
134 public int modInvokeI(string fname, params object[] parms)
135 {
136 Type returntype = m_comms.LookupReturnType(fname);
137 if (returntype != typeof(int))
138 MODError(String.Format("return type mismatch for {0}",fname));
139
140 return (int)modInvoke(fname,parms);
141 }
142
143 public float modInvokeF(string fname, params object[] parms)
144 {
145 Type returntype = m_comms.LookupReturnType(fname);
146 if (returntype != typeof(float))
147 MODError(String.Format("return type mismatch for {0}",fname));
148
149 return (float)modInvoke(fname,parms);
150 }
151
152 /// <summary>
153 /// Invokes a preregistered function through the ScriptModuleComms class
154 /// </summary>
155 /// <param name="fname">The name of the function to invoke</param>
156 /// <param name="fname">List of parameters</param>
157 /// <returns>string result of the invocation</returns>
158 protected object modInvoke(string fname, params object[] parms)
159 {
160 if (!m_MODFunctionsEnabled)
161 {
162 MODShoutError("Module command functions not enabled");
163 return "";
164 }
165
166 Type[] signature = m_comms.LookupTypeSignature(fname);
167 if (signature.Length != parms.Length)
168 MODError(String.Format("wrong number of parameters to function {0}",fname));
169
170 object[] convertedParms = new object[parms.Length];
171
172 for (int i = 0; i < parms.Length; i++)
173 {
174 if (parms[i] is LSL_String)
175 {
176 if (signature[i] != typeof(string))
177 MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name));
178
179 convertedParms[i] = (string)(LSL_String)parms[i];
180 }
181 else if (parms[i] is LSL_Integer)
182 {
183 if (signature[i] != typeof(int))
184 MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name));
185
186 convertedParms[i] = (int)(LSL_Integer)parms[i];
187 }
188 else if (parms[i] is LSL_Float)
189 {
190 if (signature[i] != typeof(float))
191 MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name));
192
193 convertedParms[i] = (float)(LSL_Float)parms[i];
194 }
195 else if (parms[i] is LSL_Key)
196 {
197 if (signature[i] != typeof(string))
198 MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name));
199
200 convertedParms[i] = (string)(LSL_Key)parms[i];
201 }
202 else if (parms[i] is LSL_Rotation)
203 {
204 if (signature[i] != typeof(string))
205 MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name));
206
207 convertedParms[i] = (string)(LSL_Rotation)parms[i];
208 }
209 else if (parms[i] is LSL_Vector)
210 {
211 if (signature[i] != typeof(string))
212 MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name));
213
214 convertedParms[i] = (string)(LSL_Vector)parms[i];
215 }
216 else
217 {
218 if (signature[i] != parms[i].GetType())
219 MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name));
220
221 convertedParms[i] = parms[i];
222 }
223 }
224
225 return m_comms.InvokeOperation(m_itemID,fname,convertedParms);
226 }
227
119 public string modSendCommand(string module, string command, string k) 228 public string modSendCommand(string module, string command, string k)
120 { 229 {
121 if (!m_MODFunctionsEnabled) 230 if (!m_MODFunctionsEnabled)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 8dfc7d2..d140c26 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -3003,5 +3003,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3003 3003
3004 return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); 3004 return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ");
3005 } 3005 }
3006
3007 /// <summary>
3008 /// Get the description from an inventory item
3009 /// </summary>
3010 /// <param name="inventoryName"></param>
3011 /// <returns>Item description</returns>
3012 public LSL_String osGetInventoryDesc(string item)
3013 {
3014 m_host.AddScriptLPS(1);
3015
3016 lock (m_host.TaskInventory)
3017 {
3018 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3019 {
3020 if (inv.Value.Name == item)
3021 {
3022 return inv.Value.Description.ToString();
3023 }
3024 }
3025 }
3026
3027 return String.Empty;
3028 }
3006 } 3029 }
3007} 3030}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs
index e08eca5..756a59f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs
@@ -40,6 +40,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
40{ 40{
41 public interface IMOD_Api 41 public interface IMOD_Api
42 { 42 {
43 // Invocation functions
44 string modInvokeS(string fname, params object[] parms);
45 int modInvokeI(string fname, params object[] parms);
46 float modInvokeF(string fname, params object[] parms);
47 // vector modInvokeV(string fname, params object[] parms);
48 // rotation modInvokeV(string fname, params object[] parms);
49 // key modInvokeK(string fname, params object[] parms);
50 // list modInvokeL(string fname, params object[] parms);
51
43 //Module functions 52 //Module functions
44 string modSendCommand(string modules, string command, string k); 53 string modSendCommand(string modules, string command, string k);
45 } 54 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index e59d3a8..1f4c4b1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -229,5 +229,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
229 LSL_List osGetAvatarList(); 229 LSL_List osGetAvatarList();
230 230
231 LSL_String osUnixTimeToTimestamp(long time); 231 LSL_String osUnixTimeToTimestamp(long time);
232
233 LSL_String osGetInventoryDesc(string item);
232 } 234 }
233} 235}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs
index 6525c76..04b7f14 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs
@@ -58,6 +58,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
58 m_MOD_Functions = (IMOD_Api)api; 58 m_MOD_Functions = (IMOD_Api)api;
59 } 59 }
60 60
61 public string modInvokeS(string fname, params object[] parms)
62 {
63 return m_MOD_Functions.modInvokeS(fname, parms);
64 }
65
66 public int modInvokeI(string fname, params object[] parms)
67 {
68 return m_MOD_Functions.modInvokeI(fname, parms);
69 }
70
71 public float modInvokeF(string fname, params object[] parms)
72 {
73 return m_MOD_Functions.modInvokeF(fname, parms);
74 }
75
61 public string modSendCommand(string module, string command, string k) 76 public string modSendCommand(string module, string command, string k)
62 { 77 {
63 return m_MOD_Functions.modSendCommand(module, command, k); 78 return m_MOD_Functions.modSendCommand(module, command, k);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index e048da2..09e5992 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -863,5 +863,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
863 { 863 {
864 return m_OSSL_Functions.osUnixTimeToTimestamp(time); 864 return m_OSSL_Functions.osUnixTimeToTimestamp(time);
865 } 865 }
866
867 public LSL_String osGetInventoryDesc(string item)
868 {
869 return m_OSSL_Functions.osGetInventoryDesc(item);
870 }
866 } 871 }
867} 872}
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
index 65d3b9b..b24f016 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
@@ -32,6 +32,8 @@ using System.Reflection;
32using log4net; 32using log4net;
33using Tools; 33using Tools;
34 34
35using OpenSim.Region.Framework.Interfaces;
36
35namespace OpenSim.Region.ScriptEngine.Shared.CodeTools 37namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
36{ 38{
37 public class CSCodeGenerator : ICodeConverter 39 public class CSCodeGenerator : ICodeConverter
@@ -45,12 +47,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
45 private int m_CSharpLine; // the current line of generated C# code 47 private int m_CSharpLine; // the current line of generated C# code
46 private int m_CSharpCol; // the current column of generated C# code 48 private int m_CSharpCol; // the current column of generated C# code
47 private List<string> m_warnings = new List<string>(); 49 private List<string> m_warnings = new List<string>();
50 private IScriptModuleComms m_comms = null;
48 51
49 /// <summary> 52 /// <summary>
50 /// Creates an 'empty' CSCodeGenerator instance. 53 /// Creates an 'empty' CSCodeGenerator instance.
51 /// </summary> 54 /// </summary>
52 public CSCodeGenerator() 55 public CSCodeGenerator()
53 { 56 {
57 m_comms = null;
58 ResetCounters();
59 }
60
61 public CSCodeGenerator(IScriptModuleComms comms)
62 {
63 m_comms = comms;
54 ResetCounters(); 64 ResetCounters();
55 } 65 }
56 66
@@ -866,8 +876,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
866 { 876 {
867 string retstr = String.Empty; 877 string retstr = String.Empty;
868 878
869 retstr += Generate(String.Format("{0}(", CheckName(fc.Id)), fc); 879 string modinvoke = null;
870 880 if (m_comms != null)
881 modinvoke = m_comms.LookupModInvocation(fc.Id);
882
883 if (modinvoke != null)
884 {
885 if (fc.kids[0] is ArgumentList)
886 {
887 if ((fc.kids[0] as ArgumentList).kids.Count == 0)
888 retstr += Generate(String.Format("{0}(\"{1}\"",modinvoke,fc.Id), fc);
889 else
890 retstr += Generate(String.Format("{0}(\"{1}\",",modinvoke,fc.Id), fc);
891 }
892 }
893 else
894 {
895 retstr += Generate(String.Format("{0}(", CheckName(fc.Id)), fc);
896 }
897
871 foreach (SYMBOL kid in fc.kids) 898 foreach (SYMBOL kid in fc.kids)
872 retstr += GenerateNode(kid); 899 retstr += GenerateNode(kid);
873 900
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
index c10143b..8f2ec49 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
@@ -35,6 +35,7 @@ using Microsoft.CSharp;
35//using Microsoft.JScript; 35//using Microsoft.JScript;
36using Microsoft.VisualBasic; 36using Microsoft.VisualBasic;
37using log4net; 37using log4net;
38
38using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.ScriptEngine.Interfaces; 40using OpenSim.Region.ScriptEngine.Interfaces;
40using OpenMetaverse; 41using OpenMetaverse;
@@ -293,6 +294,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
293 { 294 {
294// m_log.DebugFormat("[Compiler]: Compiling script\n{0}", Script); 295// m_log.DebugFormat("[Compiler]: Compiling script\n{0}", Script);
295 296
297 IScriptModuleComms comms = m_scriptEngine.World.RequestModuleInterface<IScriptModuleComms>();
298
296 linemap = null; 299 linemap = null;
297 m_warnings.Clear(); 300 m_warnings.Clear();
298 301
@@ -382,7 +385,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
382 if (language == enumCompileType.lsl) 385 if (language == enumCompileType.lsl)
383 { 386 {
384 // Its LSL, convert it to C# 387 // Its LSL, convert it to C#
385 LSL_Converter = (ICodeConverter)new CSCodeGenerator(); 388 LSL_Converter = (ICodeConverter)new CSCodeGenerator(comms);
386 compileScript = LSL_Converter.Convert(Script); 389 compileScript = LSL_Converter.Convert(Script);
387 390
388 // copy converter warnings into our warnings. 391 // copy converter warnings into our warnings.
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index f40da01..ff1f277 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -165,6 +165,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
165 165
166 public uint LocalID { get; private set; } 166 public uint LocalID { get; private set; }
167 167
168 public UUID RootObjectID { get; private set; }
169
170 public uint RootLocalID { get; private set; }
171
168 public UUID AssetID { get; private set; } 172 public UUID AssetID { get; private set; }
169 173
170 public Queue EventQueue { get; private set; } 174 public Queue EventQueue { get; private set; }
@@ -173,6 +177,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
173 177
174 public TaskInventoryItem ScriptTask { get; private set; } 178 public TaskInventoryItem ScriptTask { get; private set; }
175 179
180 public DateTime TimeStarted { get; private set; }
181
182 public long MeasurementPeriodTickStart { get; private set; }
183
184 public long MeasurementPeriodExecutionTime { get; private set; }
185
186 public static readonly long MaxMeasurementPeriod = 30 * TimeSpan.TicksPerMinute;
187
176 public void ClearQueue() 188 public void ClearQueue()
177 { 189 {
178 m_TimerQueued = false; 190 m_TimerQueued = false;
@@ -191,6 +203,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
191 Engine = engine; 203 Engine = engine;
192 LocalID = part.LocalId; 204 LocalID = part.LocalId;
193 ObjectID = part.UUID; 205 ObjectID = part.UUID;
206 RootLocalID = part.ParentGroup.LocalId;
207 RootObjectID = part.ParentGroup.UUID;
194 ItemID = itemID; 208 ItemID = itemID;
195 AssetID = assetID; 209 AssetID = assetID;
196 PrimName = primName; 210 PrimName = primName;
@@ -459,6 +473,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
459 473
460 Running = true; 474 Running = true;
461 475
476 TimeStarted = DateTime.Now;
477 MeasurementPeriodTickStart = Util.EnvironmentTickCount();
478 MeasurementPeriodExecutionTime = 0;
479
462 if (EventQueue.Count > 0) 480 if (EventQueue.Count > 0)
463 { 481 {
464 if (m_CurrentWorkItem == null) 482 if (m_CurrentWorkItem == null)
@@ -712,8 +730,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
712 m_EventStart = DateTime.Now; 730 m_EventStart = DateTime.Now;
713 m_InEvent = true; 731 m_InEvent = true;
714 732
733 int start = Util.EnvironmentTickCount();
734
735 // Reset the measurement period when we reach the end of the current one.
736 if (start - MeasurementPeriodTickStart > MaxMeasurementPeriod)
737 MeasurementPeriodTickStart = start;
738
715 m_Script.ExecuteEvent(State, data.EventName, data.Params); 739 m_Script.ExecuteEvent(State, data.EventName, data.Params);
716 740
741 MeasurementPeriodExecutionTime += Util.EnvironmentTickCount() - start;
742
717 m_InEvent = false; 743 m_InEvent = false;
718 m_CurrentEvent = String.Empty; 744 m_CurrentEvent = String.Empty;
719 745
@@ -722,7 +748,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
722 // This will be the very first event we deliver 748 // This will be the very first event we deliver
723 // (state_entry) in default state 749 // (state_entry) in default state
724 // 750 //
725
726 SaveState(m_Assembly); 751 SaveState(m_Assembly);
727 752
728 m_SaveState = false; 753 m_SaveState = false;
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index ee5f519..eb10975 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -448,6 +448,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
448 if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) 448 if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene))
449 return; 449 return;
450 450
451 MainConsole.Instance.OutputFormat(GetStatusReport());
452 }
453
454 public string GetStatusReport()
455 {
451 StringBuilder sb = new StringBuilder(); 456 StringBuilder sb = new StringBuilder();
452 sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName); 457 sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName);
453 458
@@ -475,7 +480,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
475 Listener l = AsyncCommandManager.GetListenerPlugin(this); 480 Listener l = AsyncCommandManager.GetListenerPlugin(this);
476 sb.AppendFormat("Listeners : {0}\n", l.ListenerCount); 481 sb.AppendFormat("Listeners : {0}\n", l.ListenerCount);
477 482
478 MainConsole.Instance.OutputFormat(sb.ToString()); 483 return sb.ToString();
479 } 484 }
480 485
481 public void HandleShowScripts(string module, string[] cmdparams) 486 public void HandleShowScripts(string module, string[] cmdparams)
@@ -1154,7 +1159,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1154 1159
1155 if (!m_PrimObjects[localID].Contains(itemID)) 1160 if (!m_PrimObjects[localID].Contains(itemID))
1156 m_PrimObjects[localID].Add(itemID); 1161 m_PrimObjects[localID].Add(itemID);
1157
1158 } 1162 }
1159 1163
1160 if (!m_Assemblies.ContainsKey(assetID)) 1164 if (!m_Assemblies.ContainsKey(assetID))
@@ -1981,6 +1985,59 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1981 } 1985 }
1982 } 1986 }
1983 1987
1988 public Dictionary<uint, float> GetObjectScriptsExecutionTimes()
1989 {
1990 long tickNow = Util.EnvironmentTickCount();
1991 Dictionary<uint, float> topScripts = new Dictionary<uint, float>();
1992
1993 lock (m_Scripts)
1994 {
1995 foreach (IScriptInstance si in m_Scripts.Values)
1996 {
1997 if (!topScripts.ContainsKey(si.LocalID))
1998 topScripts[si.RootLocalID] = 0;
1999
2000// long ticksElapsed = tickNow - si.MeasurementPeriodTickStart;
2001// float framesElapsed = ticksElapsed / (18.1818 * TimeSpan.TicksPerMillisecond);
2002
2003 // Execution time of the script adjusted by it's measurement period to make scripts started at
2004 // different times comparable.
2005// float adjustedExecutionTime
2006// = (float)si.MeasurementPeriodExecutionTime
2007// / ((float)(tickNow - si.MeasurementPeriodTickStart) / ScriptInstance.MaxMeasurementPeriod)
2008// / TimeSpan.TicksPerMillisecond;
2009
2010 long ticksElapsed = tickNow - si.MeasurementPeriodTickStart;
2011
2012 // Avoid divide by zerp
2013 if (ticksElapsed == 0)
2014 ticksElapsed = 1;
2015
2016 // Scale execution time to the ideal 55 fps frame time for these reasons.
2017 //
2018 // 1) XEngine does not execute scripts per frame, unlike other script engines. Hence, there is no
2019 // 'script execution time per frame', which is the original purpose of this value.
2020 //
2021 // 2) Giving the raw execution times is misleading since scripts start at different times, making
2022 // it impossible to compare scripts.
2023 //
2024 // 3) Scaling the raw execution time to the time that the script has been running is better but
2025 // is still misleading since a script that has just been rezzed may appear to have been running
2026 // for much longer.
2027 //
2028 // 4) Hence, we scale execution time to an idealised frame time (55 fps). This is also not perfect
2029 // since the figure does not represent actual execution time and very hard running scripts will
2030 // never exceed 18ms (though this is a very high number for script execution so is a warning sign).
2031 float adjustedExecutionTime
2032 = ((float)si.MeasurementPeriodExecutionTime / ticksElapsed) * 18.1818f;
2033
2034 topScripts[si.RootLocalID] += adjustedExecutionTime;
2035 }
2036 }
2037
2038 return topScripts;
2039 }
2040
1984 public void SuspendScript(UUID itemID) 2041 public void SuspendScript(UUID itemID)
1985 { 2042 {
1986// m_log.DebugFormat("[XEngine]: Received request to suspend script with ID {0}", itemID); 2043// m_log.DebugFormat("[XEngine]: Received request to suspend script with ID {0}", itemID);