aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Avatar/SitStand
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-08-20 18:13:40 +0100
committerJustin Clark-Casey (justincc)2013-08-20 18:13:40 +0100
commit43940f656210d5e572ef05bd223b3959513ee687 (patch)
treea57365253a2bfec281df894a4a6e71d9d9a9763a /OpenSim/Region/OptionalModules/Avatar/SitStand
parentAdd experimental "sit user name" and "stand user name" console commands in Si... (diff)
downloadopensim-SC_OLD-43940f656210d5e572ef05bd223b3959513ee687.zip
opensim-SC_OLD-43940f656210d5e572ef05bd223b3959513ee687.tar.gz
opensim-SC_OLD-43940f656210d5e572ef05bd223b3959513ee687.tar.bz2
opensim-SC_OLD-43940f656210d5e572ef05bd223b3959513ee687.tar.xz
Add --regex options to "sit user name" and "stand user name" console commands to sit/stand many avatars at once.
Currently, first name and last name are input separate but are concatenated with a space in the middle to form a regex. So to sit all bots with the first name "ima", for instance, the command is "sit user name --regex ima .*"
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar/SitStand')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs131
1 files changed, 81 insertions, 50 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs b/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs
index 874723c..e9cb213 100644
--- a/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs
@@ -30,18 +30,16 @@ using System.Collections.Generic;
30using System.Linq; 30using System.Linq;
31using System.Reflection; 31using System.Reflection;
32using System.Text; 32using System.Text;
33using System.Text.RegularExpressions;
33using log4net; 34using log4net;
34using Mono.Addins; 35using Mono.Addins;
36using NDesk.Options;
35using Nini.Config; 37using Nini.Config;
36using OpenMetaverse; 38using OpenMetaverse;
37using OpenSim.Framework; 39using OpenSim.Framework;
38using OpenSim.Framework.Console; 40using OpenSim.Framework.Console;
39using OpenSim.Framework.Monitoring;
40using OpenSim.Region.ClientStack.LindenUDP;
41using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes; 42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Scenes.Animation;
44using OpenSim.Services.Interfaces;
45 43
46namespace OpenSim.Region.OptionalModules.Avatar.SitStand 44namespace OpenSim.Region.OptionalModules.Avatar.SitStand
47{ 45{
@@ -92,89 +90,122 @@ namespace OpenSim.Region.OptionalModules.Avatar.SitStand
92 90
93 scene.AddCommand( 91 scene.AddCommand(
94 "Users", this, "sit user name", 92 "Users", this, "sit user name",
95 "sit user name <first-name> <last-name>", 93 "sit user name [--regex] <first-name> <last-name>",
96 "Sit the named user on an unoccupied object with a sit target.\n" 94 "Sit the named user on an unoccupied object with a sit target.",
97 + "If there are no such objects then nothing happens", 95 "If there are no such objects then nothing happens.\n"
96 + "If --regex is specified then the names are treated as regular expressions.",
98 HandleSitUserNameCommand); 97 HandleSitUserNameCommand);
99 98
100 scene.AddCommand( 99 scene.AddCommand(
101 "Users", this, "stand user name", 100 "Users", this, "stand user name",
102 "stand user name <first-name> <last-name>", 101 "stand user name [--regex] <first-name> <last-name>",
103 "Stand the named user.", 102 "Stand the named user.",
103 "If --regex is specified then the names are treated as regular expressions.",
104 HandleStandUserNameCommand); 104 HandleStandUserNameCommand);
105 } 105 }
106 106
107 protected void HandleSitUserNameCommand(string module, string[] cmd) 107 private void HandleSitUserNameCommand(string module, string[] cmd)
108 { 108 {
109 if (MainConsole.Instance.ConsoleScene != m_scene && MainConsole.Instance.ConsoleScene != null) 109 if (MainConsole.Instance.ConsoleScene != m_scene && MainConsole.Instance.ConsoleScene != null)
110 return; 110 return;
111 111
112 if (cmd.Length != 5) 112 if (cmd.Length < 5)
113 { 113 {
114 MainConsole.Instance.Output("Usage: sit user name <first-name> <last-name>"); 114 MainConsole.Instance.Output("Usage: sit user name [--regex] <first-name> <last-name>");
115 return; 115 return;
116 } 116 }
117 117
118 string firstName = cmd[3]; 118 List<ScenePresence> scenePresences = GetScenePresences(cmd);
119 string lastName = cmd[4];
120 119
121 ScenePresence sp = m_scene.GetScenePresence(firstName, lastName); 120 foreach (ScenePresence sp in scenePresences)
122
123 if (sp == null || sp.IsChildAgent)
124 return;
125
126 SceneObjectPart sitPart = null;
127 List<SceneObjectGroup> sceneObjects = m_scene.GetSceneObjectGroups();
128
129 foreach (SceneObjectGroup sceneObject in sceneObjects)
130 { 121 {
131 foreach (SceneObjectPart part in sceneObject.Parts) 122 SceneObjectPart sitPart = null;
123 List<SceneObjectGroup> sceneObjects = m_scene.GetSceneObjectGroups();
124
125 foreach (SceneObjectGroup sceneObject in sceneObjects)
132 { 126 {
133 if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero) 127 foreach (SceneObjectPart part in sceneObject.Parts)
134 { 128 {
135 sitPart = part; 129 if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero)
136 break; 130 {
131 sitPart = part;
132 break;
133 }
137 } 134 }
138 } 135 }
139 }
140 136
141 if (sitPart != null) 137 if (sitPart != null)
142 { 138 {
143 MainConsole.Instance.OutputFormat( 139 MainConsole.Instance.OutputFormat(
144 "Sitting {0} on {1} {2} in {3}", 140 "Sitting {0} on {1} {2} in {3}",
145 sp.Name, sitPart.ParentGroup.Name, sitPart.ParentGroup.UUID, m_scene.Name); 141 sp.Name, sitPart.ParentGroup.Name, sitPart.ParentGroup.UUID, m_scene.Name);
146 142
147 sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, sitPart.UUID, Vector3.Zero); 143 sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, sitPart.UUID, Vector3.Zero);
148 sp.HandleAgentSit(sp.ControllingClient, sp.UUID); 144 sp.HandleAgentSit(sp.ControllingClient, sp.UUID);
149 } 145 }
150 else 146 else
151 { 147 {
152 MainConsole.Instance.OutputFormat( 148 MainConsole.Instance.OutputFormat(
153 "Could not find any unoccupied set seat on which to sit {0} in {1}", 149 "Could not find any unoccupied set seat on which to sit {0} in {1}. Aborting",
154 sp.Name, m_scene.Name); 150 sp.Name, m_scene.Name);
151
152 break;
153 }
155 } 154 }
156 } 155 }
157 156
158 protected void HandleStandUserNameCommand(string module, string[] cmd) 157 private void HandleStandUserNameCommand(string module, string[] cmd)
159 { 158 {
160 if (MainConsole.Instance.ConsoleScene != m_scene && MainConsole.Instance.ConsoleScene != null) 159 if (MainConsole.Instance.ConsoleScene != m_scene && MainConsole.Instance.ConsoleScene != null)
161 return; 160 return;
162 161
163 if (cmd.Length != 5) 162 if (cmd.Length < 5)
164 { 163 {
165 MainConsole.Instance.Output("Usage: stand user name <first-name> <last-name>"); 164 MainConsole.Instance.Output("Usage: stand user name [--regex] <first-name> <last-name>");
166 return; 165 return;
167 } 166 }
168 167
169 string firstName = cmd[3]; 168 List<ScenePresence> scenePresences = GetScenePresences(cmd);
170 string lastName = cmd[4];
171 169
172 ScenePresence sp = m_scene.GetScenePresence(firstName, lastName); 170 foreach (ScenePresence sp in scenePresences)
173 171 {
174 if (sp == null || sp.IsChildAgent) 172 MainConsole.Instance.OutputFormat("Standing {0} in {1}", sp.Name, m_scene.Name);
175 return; 173 sp.StandUp();
174 }
175 }
176
177 private List<ScenePresence> GetScenePresences(string[] cmdParams)
178 {
179 bool useRegex = false;
180 OptionSet options = new OptionSet().Add("regex", v=> useRegex = v != null );
181
182 List<string> mainParams = options.Parse(cmdParams);
183
184 string firstName = mainParams[3];
185 string lastName = mainParams[4];
186
187 List<ScenePresence> scenePresencesMatched = new List<ScenePresence>();
188
189 if (useRegex)
190 {
191 Regex nameRegex = new Regex(string.Format("{0} {1}", firstName, lastName));
192 List<ScenePresence> scenePresences = m_scene.GetScenePresences();
193
194 foreach (ScenePresence sp in scenePresences)
195 {
196 if (!sp.IsChildAgent && nameRegex.IsMatch(sp.Name))
197 scenePresencesMatched.Add(sp);
198 }
199 }
200 else
201 {
202 ScenePresence sp = m_scene.GetScenePresence(firstName, lastName);
203
204 if (sp != null && !sp.IsChildAgent)
205 scenePresencesMatched.Add(sp);
206 }
176 207
177 sp.StandUp(); 208 return scenePresencesMatched;
178 } 209 }
179 } 210 }
180} \ No newline at end of file 211} \ No newline at end of file