diff options
author | Justin Clark-Casey (justincc) | 2011-12-07 17:31:57 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-12-07 17:31:57 +0000 |
commit | 415b7b7ec4be9f87e7d5b65000e092d3372a4391 (patch) | |
tree | 315ba0fc1f42a542a274b997b0d62a490ef78e73 | |
parent | properly lock CapsHandlers.m_capsHandlers (diff) | |
download | opensim-SC_OLD-415b7b7ec4be9f87e7d5b65000e092d3372a4391.zip opensim-SC_OLD-415b7b7ec4be9f87e7d5b65000e092d3372a4391.tar.gz opensim-SC_OLD-415b7b7ec4be9f87e7d5b65000e092d3372a4391.tar.bz2 opensim-SC_OLD-415b7b7ec4be9f87e7d5b65000e092d3372a4391.tar.xz |
Implement XMLRPCAdmin command admin_teleport_agent.
This allows someone with access to this command on the XMLRPCAdmin interface to teleport an avatar to an arbitrary region and/or position.
-rw-r--r-- | OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 113 | ||||
-rw-r--r-- | OpenSim/Framework/IScene.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 6 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneBase.cs | 6 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneManager.cs | 33 |
5 files changed, 157 insertions, 5 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index a634f1c..1b289a6 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | |||
@@ -134,16 +134,22 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
134 | availableMethods["admin_restart"] = XmlRpcRestartMethod; | 134 | availableMethods["admin_restart"] = XmlRpcRestartMethod; |
135 | availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod; | 135 | availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod; |
136 | availableMethods["admin_save_heightmap"] = XmlRpcSaveHeightmapMethod; | 136 | availableMethods["admin_save_heightmap"] = XmlRpcSaveHeightmapMethod; |
137 | |||
138 | // Agent management | ||
139 | availableMethods["admin_teleport_agent"] = XmlRpcTeleportAgentMethod; | ||
140 | |||
137 | // User management | 141 | // User management |
138 | availableMethods["admin_create_user"] = XmlRpcCreateUserMethod; | 142 | availableMethods["admin_create_user"] = XmlRpcCreateUserMethod; |
139 | availableMethods["admin_create_user_email"] = XmlRpcCreateUserMethod; | 143 | availableMethods["admin_create_user_email"] = XmlRpcCreateUserMethod; |
140 | availableMethods["admin_exists_user"] = XmlRpcUserExistsMethod; | 144 | availableMethods["admin_exists_user"] = XmlRpcUserExistsMethod; |
141 | availableMethods["admin_update_user"] = XmlRpcUpdateUserAccountMethod; | 145 | availableMethods["admin_update_user"] = XmlRpcUpdateUserAccountMethod; |
146 | |||
142 | // Region state management | 147 | // Region state management |
143 | availableMethods["admin_load_xml"] = XmlRpcLoadXMLMethod; | 148 | availableMethods["admin_load_xml"] = XmlRpcLoadXMLMethod; |
144 | availableMethods["admin_save_xml"] = XmlRpcSaveXMLMethod; | 149 | availableMethods["admin_save_xml"] = XmlRpcSaveXMLMethod; |
145 | availableMethods["admin_load_oar"] = XmlRpcLoadOARMethod; | 150 | availableMethods["admin_load_oar"] = XmlRpcLoadOARMethod; |
146 | availableMethods["admin_save_oar"] = XmlRpcSaveOARMethod; | 151 | availableMethods["admin_save_oar"] = XmlRpcSaveOARMethod; |
152 | |||
147 | // Estate access list management | 153 | // Estate access list management |
148 | availableMethods["admin_acl_clear"] = XmlRpcAccessListClear; | 154 | availableMethods["admin_acl_clear"] = XmlRpcAccessListClear; |
149 | availableMethods["admin_acl_add"] = XmlRpcAccessListAdd; | 155 | availableMethods["admin_acl_add"] = XmlRpcAccessListAdd; |
@@ -2965,6 +2971,112 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
2965 | return response; | 2971 | return response; |
2966 | } | 2972 | } |
2967 | 2973 | ||
2974 | public XmlRpcResponse XmlRpcTeleportAgentMethod(XmlRpcRequest request, IPEndPoint remoteClient) | ||
2975 | { | ||
2976 | XmlRpcResponse response = new XmlRpcResponse(); | ||
2977 | Hashtable responseData = new Hashtable(); | ||
2978 | |||
2979 | try | ||
2980 | { | ||
2981 | responseData["success"] = true; | ||
2982 | |||
2983 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
2984 | |||
2985 | CheckStringParameters(request, new string[] {"password"}); | ||
2986 | |||
2987 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | ||
2988 | |||
2989 | UUID agentId; | ||
2990 | string regionName = null; | ||
2991 | Vector3 pos, lookAt; | ||
2992 | bool agentSpecified = false; | ||
2993 | ScenePresence sp = null; | ||
2994 | |||
2995 | if (requestData.Contains("agent_first_name") && requestData.Contains("agent_last_name")) | ||
2996 | { | ||
2997 | string firstName = requestData["agent_first_name"].ToString(); | ||
2998 | string lastName = requestData["agent_last_name"].ToString(); | ||
2999 | m_application.SceneManager.TryGetRootScenePresenceByName(firstName, lastName, out sp); | ||
3000 | |||
3001 | if (sp == null) | ||
3002 | throw new Exception( | ||
3003 | string.Format( | ||
3004 | "No agent found with agent_first_name {0} and agent_last_name {1}", firstName, lastName)); | ||
3005 | } | ||
3006 | else if (requestData.Contains("agent_id")) | ||
3007 | { | ||
3008 | string rawAgentId = (string)requestData["agent_id"]; | ||
3009 | |||
3010 | if (!UUID.TryParse(rawAgentId, out agentId)) | ||
3011 | throw new Exception(string.Format("agent_id {0} does not have the correct id format", rawAgentId)); | ||
3012 | |||
3013 | m_application.SceneManager.TryGetRootScenePresence(agentId, out sp); | ||
3014 | |||
3015 | if (sp == null) | ||
3016 | throw new Exception(string.Format("No agent with agent_id {0} found in this simulator", agentId)); | ||
3017 | } | ||
3018 | else | ||
3019 | { | ||
3020 | throw new Exception("No agent_id or agent_first_name and agent_last_name parameters specified"); | ||
3021 | } | ||
3022 | |||
3023 | if (requestData.Contains("region_name")) | ||
3024 | regionName = (string)requestData["region_name"]; | ||
3025 | |||
3026 | pos.X = ParseFloat(requestData, "pos_x", sp.AbsolutePosition.X); | ||
3027 | pos.Y = ParseFloat(requestData, "pos_y", sp.AbsolutePosition.Y); | ||
3028 | pos.Z = ParseFloat(requestData, "pos_z", sp.AbsolutePosition.Z); | ||
3029 | lookAt.X = ParseFloat(requestData, "lookat_x", sp.Lookat.X); | ||
3030 | lookAt.Y = ParseFloat(requestData, "lookat_y", sp.Lookat.Y); | ||
3031 | lookAt.Z = ParseFloat(requestData, "lookat_z", sp.Lookat.Z); | ||
3032 | |||
3033 | sp.Scene.RequestTeleportLocation( | ||
3034 | sp.ControllingClient, regionName, pos, lookAt, (uint)Constants.TeleportFlags.ViaLocation); | ||
3035 | } | ||
3036 | catch (Exception e) | ||
3037 | { | ||
3038 | m_log.ErrorFormat("[RADMIN]: admin_teleport_agent exception: {0}{1}", e.Message, e.StackTrace); | ||
3039 | |||
3040 | responseData["success"] = false; | ||
3041 | responseData["error"] = e.Message; | ||
3042 | } | ||
3043 | finally | ||
3044 | { | ||
3045 | response.Value = responseData; | ||
3046 | } | ||
3047 | |||
3048 | return response; | ||
3049 | } | ||
3050 | |||
3051 | /// <summary> | ||
3052 | /// Parse a float with the given parameter name from a request data hash table. | ||
3053 | /// </summary> | ||
3054 | /// <remarks> | ||
3055 | /// Will throw an exception if parameter is not a float. | ||
3056 | /// Will not throw if parameter is not found, passes back default value instead. | ||
3057 | /// </remarks> | ||
3058 | /// <param name="requestData"></param> | ||
3059 | /// <param name="paramName"></param> | ||
3060 | /// <param name="defaultVal"></param> | ||
3061 | /// <returns></returns> | ||
3062 | private static float ParseFloat(Hashtable requestData, string paramName, float defaultVal) | ||
3063 | { | ||
3064 | if (requestData.Contains(paramName)) | ||
3065 | { | ||
3066 | string rawVal = (string)requestData[paramName]; | ||
3067 | float val; | ||
3068 | |||
3069 | if (!float.TryParse(rawVal, out val)) | ||
3070 | throw new Exception(string.Format("{0} {1} is not a valid float", paramName, rawVal)); | ||
3071 | else | ||
3072 | return val; | ||
3073 | } | ||
3074 | else | ||
3075 | { | ||
3076 | return defaultVal; | ||
3077 | } | ||
3078 | } | ||
3079 | |||
2968 | private static void CheckStringParameters(XmlRpcRequest request, string[] param) | 3080 | private static void CheckStringParameters(XmlRpcRequest request, string[] param) |
2969 | { | 3081 | { |
2970 | Hashtable requestData = (Hashtable) request.Params[0]; | 3082 | Hashtable requestData = (Hashtable) request.Params[0]; |
@@ -3144,6 +3256,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
3144 | return false; | 3256 | return false; |
3145 | } | 3257 | } |
3146 | } | 3258 | } |
3259 | |||
3147 | private bool LoadHeightmap(string file, UUID regionID) | 3260 | private bool LoadHeightmap(string file, UUID regionID) |
3148 | { | 3261 | { |
3149 | m_log.InfoFormat("[RADMIN]: Terrain Loading: {0}", file); | 3262 | m_log.InfoFormat("[RADMIN]: Terrain Loading: {0}", file); |
diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs index 76b731f..7b0fe37 100644 --- a/OpenSim/Framework/IScene.cs +++ b/OpenSim/Framework/IScene.cs | |||
@@ -90,9 +90,9 @@ namespace OpenSim.Framework | |||
90 | /// <summary> | 90 | /// <summary> |
91 | /// Is the agent denoted by the given agentID a child presence in this scene? | 91 | /// Is the agent denoted by the given agentID a child presence in this scene? |
92 | /// </summary> | 92 | /// </summary> |
93 | /// | 93 | /// <remarks> |
94 | /// Used by ClientView when a 'kick everyone' or 'estate message' occurs | 94 | /// Used by ClientView when a 'kick everyone' or 'estate message' occurs |
95 | /// | 95 | /// </remarks> |
96 | /// <param name="avatarID">AvatarID to lookup</param> | 96 | /// <param name="avatarID">AvatarID to lookup</param> |
97 | /// <returns>true if the presence is a child agent, false if the presence is a root exception</returns> | 97 | /// <returns>true if the presence is a child agent, false if the presence is a root exception</returns> |
98 | /// <exception cref="System.NullReferenceException"> | 98 | /// <exception cref="System.NullReferenceException"> |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 3ac6327..604f035 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -4206,7 +4206,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4206 | /// <param name="action"></param> | 4206 | /// <param name="action"></param> |
4207 | public void ForEachRootScenePresence(Action<ScenePresence> action) | 4207 | public void ForEachRootScenePresence(Action<ScenePresence> action) |
4208 | { | 4208 | { |
4209 | if(m_sceneGraph != null) | 4209 | if (m_sceneGraph != null) |
4210 | { | 4210 | { |
4211 | m_sceneGraph.ForEachAvatar(action); | 4211 | m_sceneGraph.ForEachAvatar(action); |
4212 | } | 4212 | } |
@@ -4286,9 +4286,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
4286 | return m_sceneGraph.GetGroupByPrim(localID); | 4286 | return m_sceneGraph.GetGroupByPrim(localID); |
4287 | } | 4287 | } |
4288 | 4288 | ||
4289 | public override bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) | 4289 | public override bool TryGetScenePresence(UUID agentID, out ScenePresence sp) |
4290 | { | 4290 | { |
4291 | return m_sceneGraph.TryGetScenePresence(avatarId, out avatar); | 4291 | return m_sceneGraph.TryGetScenePresence(agentID, out sp); |
4292 | } | 4292 | } |
4293 | 4293 | ||
4294 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) | 4294 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 0336fe5..a633c72 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -191,6 +191,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
191 | return false; | 191 | return false; |
192 | } | 192 | } |
193 | 193 | ||
194 | /// <summary> | ||
195 | /// Try to get a scene presence from the scene | ||
196 | /// </summary> | ||
197 | /// <param name="agentID"></param> | ||
198 | /// <param name="scenePresence">null if there is no scene presence with the given agent id</param> | ||
199 | /// <returns>true if there was a scene presence with the given id, false otherwise.</returns> | ||
194 | public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence); | 200 | public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence); |
195 | 201 | ||
196 | #endregion | 202 | #endregion |
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index 82458e2..0491205 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs | |||
@@ -545,6 +545,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
545 | return false; | 545 | return false; |
546 | } | 546 | } |
547 | 547 | ||
548 | public bool TryGetRootScenePresence(UUID avatarId, out ScenePresence avatar) | ||
549 | { | ||
550 | lock (m_localScenes) | ||
551 | { | ||
552 | foreach (Scene scene in m_localScenes) | ||
553 | { | ||
554 | avatar = scene.GetScenePresence(avatarId); | ||
555 | |||
556 | if (avatar != null && !avatar.IsChildAgent) | ||
557 | return true; | ||
558 | } | ||
559 | } | ||
560 | |||
561 | avatar = null; | ||
562 | return false; | ||
563 | } | ||
564 | |||
548 | public bool TryGetAvatarsScene(UUID avatarId, out Scene scene) | 565 | public bool TryGetAvatarsScene(UUID avatarId, out Scene scene) |
549 | { | 566 | { |
550 | ScenePresence avatar = null; | 567 | ScenePresence avatar = null; |
@@ -590,6 +607,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
590 | return false; | 607 | return false; |
591 | } | 608 | } |
592 | 609 | ||
610 | public bool TryGetRootScenePresenceByName(string firstName, string lastName, out ScenePresence sp) | ||
611 | { | ||
612 | lock (m_localScenes) | ||
613 | { | ||
614 | foreach (Scene scene in m_localScenes) | ||
615 | { | ||
616 | sp = scene.GetScenePresence(firstName, lastName); | ||
617 | if (sp != null && !sp.IsChildAgent) | ||
618 | return true; | ||
619 | } | ||
620 | } | ||
621 | |||
622 | sp = null; | ||
623 | return false; | ||
624 | } | ||
625 | |||
593 | public void ForEachScene(Action<Scene> action) | 626 | public void ForEachScene(Action<Scene> action) |
594 | { | 627 | { |
595 | lock (m_localScenes) | 628 | lock (m_localScenes) |