aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application/OpenSim.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Application/OpenSim.cs')
-rw-r--r--OpenSim/Region/Application/OpenSim.cs1033
1 files changed, 508 insertions, 525 deletions
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index af42a3d..37066c2 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -49,7 +49,7 @@ namespace OpenSim
49 /// <summary> 49 /// <summary>
50 /// Interactive OpenSim region server 50 /// Interactive OpenSim region server
51 /// </summary> 51 /// </summary>
52 public class OpenSim : OpenSimBase, conscmd_callback 52 public class OpenSim : OpenSimBase
53 { 53 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 55
@@ -59,11 +59,6 @@ namespace OpenSim
59 private string m_timedScript = "disabled"; 59 private string m_timedScript = "disabled";
60 private Timer m_scriptTimer; 60 private Timer m_scriptTimer;
61 61
62 /// <summary>
63 /// List of Console Plugin Commands
64 /// </summary>
65 private static List<ConsolePluginCommand> m_PluginCommandInfos = new List<ConsolePluginCommand>();
66
67 public OpenSim(IConfigSource configSource) : base(configSource) 62 public OpenSim(IConfigSource configSource) : base(configSource)
68 { 63 {
69 } 64 }
@@ -97,9 +92,189 @@ namespace OpenSim
97 //GCSettings.LatencyMode = GCLatencyMode.Batch; 92 //GCSettings.LatencyMode = GCLatencyMode.Batch;
98 //m_log.InfoFormat("[OPENSIM MAIN]: GC Latency Mode: {0}", GCSettings.LatencyMode.ToString()); 93 //m_log.InfoFormat("[OPENSIM MAIN]: GC Latency Mode: {0}", GCSettings.LatencyMode.ToString());
99 94
100 m_console = new ConsoleBase("Region", this); 95 m_console = new ConsoleBase("Region");
101 MainConsole.Instance = m_console; 96 MainConsole.Instance = m_console;
102 97
98 m_console.Commands.AddCommand("region", "clear assets",
99 "clear assets",
100 "Clear the asset cache", HandleClearAssets);
101
102 m_console.Commands.AddCommand("region", "force update",
103 "force update",
104 "Force the update of all objects on clients",
105 HandleForceUpdate);
106
107 m_console.Commands.AddCommand("region", "debug packet",
108 "debug packet <level>",
109 "Turn on packet debugging", Debug);
110
111 m_console.Commands.AddCommand("region", "debug scene",
112 "debug scene <cripting> <collisions> <physics>",
113 "Turn on scene debugging", Debug);
114
115 m_console.Commands.AddCommand("region", "change region",
116 "change region <region name>",
117 "Change current console region", ChangeSelectedRegion);
118
119 m_console.Commands.AddCommand("region", "save xml",
120 "save xml",
121 "Save a region's data in XML format", SaveXml);
122
123 m_console.Commands.AddCommand("region", "save xml2",
124 "save xml2",
125 "Save a region's data in XML2 format", SaveXml2);
126
127 m_console.Commands.AddCommand("region", "load xml",
128 "load xml [-newIDs [<x> <y> <z>]]",
129 "Load a region's data from XML format", LoadXml);
130
131 m_console.Commands.AddCommand("region", "load xml2",
132 "load xml2",
133 "Load a region's data from XML2 format", LoadXml2);
134
135 m_console.Commands.AddCommand("region", "save prims xml2",
136 "save prims xml2 [<prim name> <file name>]",
137 "Save named prim to XML2", SavePrimsXml2);
138
139 m_console.Commands.AddCommand("region", "load oar",
140 "load oar <oar name>",
141 "Load a region's data from OAR archive", LoadOar);
142
143 m_console.Commands.AddCommand("region", "save oar",
144 "save oar <oar name>",
145 "Save a region's data to an OAR archive", SaveOar);
146
147 m_console.Commands.AddCommand("region", "save inventory",
148 "save inventory <first> <last> <path> <file>",
149 "Save user inventory data", SaveInv);
150
151 m_console.Commands.AddCommand("region", "load inventory",
152 "load inventory <first> <last> <path> <file>",
153 "Load user inventory data", LoadInv);
154
155 m_console.Commands.AddCommand("region", "edit scale",
156 "edit scale <name> <x> <y> <z>",
157 "Change the scale of a named prim", HandleEditScale);
158
159 m_console.Commands.AddCommand("region", "kick user",
160 "kick user <first> <last>",
161 "Kick a user off the simulator", HandleEditScale);
162
163 m_console.Commands.AddCommand("region", "show assets",
164 "show assets",
165 "Show asset data", HandleShow);
166
167 m_console.Commands.AddCommand("region", "show users",
168 "show users [full]",
169 "Show user data", HandleShow);
170
171 m_console.Commands.AddCommand("region", "show users full",
172 "show users full",
173 String.Empty, HandleShow);
174
175 m_console.Commands.AddCommand("region", "show modules",
176 "show modules",
177 "Show module data", HandleShow);
178
179 m_console.Commands.AddCommand("region", "show regions",
180 "show regions",
181 "Show region data", HandleShow);
182
183 m_console.Commands.AddCommand("region", "show queues",
184 "show queues",
185 "Show queue data", HandleShow);
186
187 m_console.Commands.AddCommand("region", "alert",
188 "alert <first> <last> <message>",
189 "Send an alert to a user", RunCommand);
190
191 m_console.Commands.AddCommand("region", "alert general",
192 "alert general <message>",
193 "Send an alert everyone", RunCommand);
194
195 m_console.Commands.AddCommand("region", "backup",
196 "backup",
197 "Persist objects to the database now", RunCommand);
198
199 m_console.Commands.AddCommand("region", "create region",
200 "create region",
201 "Create a new region", HandleCreateRegion);
202
203 m_console.Commands.AddCommand("region", "login enable",
204 "login enable",
205 "Enable logins to the simulator", HandleLoginEnable);
206
207 m_console.Commands.AddCommand("region", "login disable",
208 "login disable",
209 "Disable logins to the simulator", HandleLoginDisable);
210
211 m_console.Commands.AddCommand("region", "login status",
212 "login status",
213 "Display status of logins", HandleLoginStatus);
214
215 m_console.Commands.AddCommand("region", "restart",
216 "restart",
217 "Restart all sims in this instance", RunCommand);
218
219 m_console.Commands.AddCommand("region", "config set",
220 "config set <section> <field> <value>",
221 "Set a config option", HandleConfig);
222
223 m_console.Commands.AddCommand("region", "config get",
224 "config get <section> <field>",
225 "Read a config option", HandleConfig);
226
227 m_console.Commands.AddCommand("region", "config save",
228 "config save",
229 "Save current configuration", HandleConfig);
230
231 m_console.Commands.AddCommand("region", "command-script",
232 "command-script <script>",
233 "Run a command script from file", RunCommand);
234
235 m_console.Commands.AddCommand("region", "export-map",
236 "export-map <file>",
237 "Save an image of the world map", RunCommand);
238
239 m_console.Commands.AddCommand("region", "remove-region",
240 "remove-region <name>",
241 "Remove a region from this simulator", RunCommand);
242
243 m_console.Commands.AddCommand("region", "delete-region",
244 "delete-region <name>",
245 "Delete a region from disk", RunCommand);
246
247 m_console.Commands.AddCommand("region", "predecode-j2k",
248 "predecode-j2k [<num threads>]>",
249 "Precache assets,decode j2k layerdata", RunCommand);
250
251 m_console.Commands.AddCommand("region", "modules list",
252 "modules list",
253 "List modules", HandleModules);
254
255 m_console.Commands.AddCommand("region", "modules load",
256 "modules load <name>",
257 "Load a module", HandleModules);
258
259 m_console.Commands.AddCommand("region", "modules unload",
260 "modules unload <name>",
261 "Unload a module", HandleModules);
262
263 m_console.Commands.AddCommand("region", "Add-InventoryHost",
264 "Add-InventoryHost <host>",
265 String.Empty, RunCommand);
266
267 if (ConfigurationSettings.Standalone)
268 {
269 m_console.Commands.AddCommand("region", "create user",
270 "create user [<first> [<last> [<pass> [<x> <y> [<email>]]]]]",
271 "Create a new user", HandleCreateUser);
272
273 m_console.Commands.AddCommand("region", "reset user password",
274 "reset user password [<first> [<last> [<password>]]]",
275 "Reset a user password", HandleResetUserPassword);
276 }
277
103 base.StartupSpecific(); 278 base.StartupSpecific();
104 279
105 //Run Startup Commands 280 //Run Startup Commands
@@ -122,11 +297,9 @@ namespace OpenSim
122 } 297 }
123 298
124 PrintFileToConsole("startuplogo.txt"); 299 PrintFileToConsole("startuplogo.txt");
125 RegisterCmd("echoTest", RunEchoTest, "this echos your command args to see how they are parsed");
126 RegisterCmd("kickuser", KickUserCommand, "kickuser [first] [last] - attempts to log off a user from any region we are serving");
127 300
128 // For now, start at the 'root' level by default 301 // For now, start at the 'root' level by default
129 ChangeSelectedRegion(new string[] {"root"}); 302 ChangeSelectedRegion("region", new string[] {"change", "region", "root"});
130 } 303 }
131 304
132 public override void ShutdownSpecific() 305 public override void ShutdownSpecific()
@@ -148,17 +321,9 @@ namespace OpenSim
148 321
149 #region Console Commands 322 #region Console Commands
150 323
151 private void RunEchoTest(string[] cmdparams) 324 private void KickUserCommand(string module, string[] cmdparams)
152 { 325 {
153 for (int i = 0; i < cmdparams.Length; i++) 326 if (cmdparams.Length < 4)
154 {
155 m_log.Info("[EchoTest]: <arg" + i + ">"+cmdparams[i]+"</arg" + i + ">");
156 }
157 }
158
159 private void KickUserCommand(string[] cmdparams)
160 {
161 if (cmdparams.Length < 2)
162 return; 327 return;
163 328
164 IList agents = m_sceneManager.GetCurrentSceneAvatars(); 329 IList agents = m_sceneManager.GetCurrentSceneAvatars();
@@ -167,7 +332,7 @@ namespace OpenSim
167 { 332 {
168 RegionInfo regionInfo = m_sceneManager.GetRegionInfo(presence.RegionHandle); 333 RegionInfo regionInfo = m_sceneManager.GetRegionInfo(presence.RegionHandle);
169 334
170 if (presence.Firstname.ToLower().Contains(cmdparams[0].ToLower()) && presence.Lastname.ToLower().Contains(cmdparams[1].ToLower())) 335 if (presence.Firstname.ToLower().Contains(cmdparams[2].ToLower()) && presence.Lastname.ToLower().Contains(cmdparams[3].ToLower()))
171 { 336 {
172 m_console.Notice( 337 m_console.Notice(
173 String.Format( 338 String.Format(
@@ -219,302 +384,261 @@ namespace OpenSim
219 } 384 }
220 } 385 }
221 386
222 /// <summary> 387 private void HandleClearAssets(string module, string[] args)
223 /// Runs commands issued by the server console from the operator
224 /// </summary>
225 /// <param name="command">The first argument of the parameter (the command)</param>
226 /// <param name="cmdparams">Additional arguments passed to the command</param>
227 public override void RunCmd(string command, string[] cmdparams)
228 { 388 {
229 base.RunCmd(command, cmdparams); 389 m_assetCache.Clear();
230 RunPluginCommands(command , cmdparams); 390 }
231
232 switch (command)
233 {
234 case "clear-assets":
235 m_assetCache.Clear();
236 break;
237
238 case "force-update":
239 m_console.Notice("Updating all clients");
240 m_sceneManager.ForceCurrentSceneClientUpdate();
241 break;
242
243 case "edit-scale":
244 if (cmdparams.Length == 4)
245 {
246 m_sceneManager.HandleEditCommandOnCurrentScene(cmdparams);
247 }
248 break;
249
250 case "debug":
251 Debug(cmdparams);
252 break;
253
254 case "save-xml":
255 SaveXml(cmdparams);
256 break;
257
258 case "load-xml":
259 LoadXml(cmdparams);
260 break;
261
262 case "save-xml2":
263 SaveXml2(cmdparams);
264 break;
265 391
266 case "load-xml2": 392 private void HandleForceUpdate(string module, string[] args)
267 LoadXml2(cmdparams); 393 {
268 break; 394 m_console.Notice("Updating all clients");
395 m_sceneManager.ForceCurrentSceneClientUpdate();
396 }
269 397
270 case "save-prims-xml2": 398 private void HandleEditScale(string module, string[] args)
271 if (cmdparams.Length > 1) 399 {
272 { 400 if (args.Length == 5)
273 m_sceneManager.SaveNamedPrimsToXml2(cmdparams[0], cmdparams[1]); 401 {
274 } 402 m_sceneManager.HandleEditCommandOnCurrentScene(args);
275 else 403 }
276 { 404 else
277 m_sceneManager.SaveNamedPrimsToXml2("Primitive", DEFAULT_PRIM_BACKUP_FILENAME); 405 {
278 } 406 m_console.Notice("Argument error: edit scale <prim name> <x> <y> <z>");
279 break; 407 }
408 }
280 409
281 case "load-oar": 410 private void HandleCreateRegion(string module, string[] cmd)
282 LoadOar(cmdparams); 411 {
283 break; 412 if (cmd.Length < 4)
413 {
414 m_console.Error("Usage: create region <region name> <region_file.xml>");
415 return;
416 }
284 417
285 case "save-oar": 418 string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim();
286 SaveOar(cmdparams); 419 string regionFile = String.Format("{0}/{1}", regionsDir, cmd[3]);
287 break; 420 // Allow absolute and relative specifiers
421 if (cmd[3].StartsWith("/") || cmd[3].StartsWith("\\") || cmd[3].StartsWith(".."))
422 regionFile = cmd[3];
288 423
289 case "save-inv": 424 CreateRegion(new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source), true);
290 SaveInv(cmdparams); 425 }
291 break;
292 426
293 case "load-inv": 427 private void HandleLoginEnable(string module, string[] cmd)
294 LoadInv(cmdparams); 428 {
295 break; 429 ProcessLogin(true);
430 }
296 431
297 case "plugin": 432 private void HandleLoginDisable(string module, string[] cmd)
298 m_sceneManager.SendCommandToPluginModules(cmdparams); 433 {
299 break; 434 ProcessLogin(false);
435 }
300 436
301 case "command-script": 437 private void HandleLoginStatus(string module, string[] cmd)
302 if (cmdparams.Length > 0) 438 {
303 { 439 if (m_commsManager.GridService.RegionLoginsEnabled == false)
304 RunCommandScript(cmdparams[0]);
305 }
306 break;
307 440
308 case "backup": 441 m_log.Info("[ Login ] Login are disabled ");
309 m_sceneManager.BackupCurrentScene(); 442 else
310 break; 443 m_log.Info("[ Login ] Login are enabled");
444 }
311 445
312 case "alert": 446 private void HandleConfig(string module, string[] cmd)
313 m_sceneManager.HandleAlertCommandOnCurrentScene(cmdparams); 447 {
314 break; 448 List<string> args = new List<string>(cmd);
449 args.RemoveAt(0);
450 string[] cmdparams = args.ToArray();
451 string n = "CONFIG";
315 452
316 case "create": 453 if (cmdparams.Length > 0)
317 Create(cmdparams); 454 {
318 break; 455 switch (cmdparams[0].ToLower())
456 {
457 case "set":
458 if (cmdparams.Length < 4)
459 {
460 m_console.Error(n, "SYNTAX: " + n + " SET SECTION KEY VALUE");
461 m_console.Error(n, "EXAMPLE: " + n + " SET ScriptEngine.DotNetEngine NumberOfScriptThreads 5");
462 }
463 else
464 {
465 // IConfig c = DefaultConfig().Configs[cmdparams[1]];
466 // if (c == null)
467 // c = DefaultConfig().AddConfig(cmdparams[1]);
468 IConfig c;
469 IConfigSource source = new IniConfigSource();
470 c = source.AddConfig(cmdparams[1]);
471 if (c != null)
472 {
473 string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3);
474 c.Set(cmdparams[2], _value);
475 m_config.Source.Merge(source);
319 476
320 case "login-enable": 477 m_console.Error(n, n + " " + n + " " + cmdparams[1] + " " + cmdparams[2] + " " +
321 ProcessLogin(true); 478 _value);
322 break; 479 }
323 case "login-disable": 480 }
324 ProcessLogin(false); 481 break;
325 break; 482 case "get":
326 case "login-status": 483 if (cmdparams.Length < 3)
327 if (m_commsManager.GridService.RegionLoginsEnabled == false) 484 {
485 m_console.Error(n, "SYNTAX: " + n + " GET SECTION KEY");
486 m_console.Error(n, "EXAMPLE: " + n + " GET ScriptEngine.DotNetEngine NumberOfScriptThreads");
487 }
488 else
489 {
490 IConfig c = m_config.Source.Configs[cmdparams[1]]; // DefaultConfig().Configs[cmdparams[1]];
491 if (c == null)
492 {
493 m_console.Notice(n, "Section \"" + cmdparams[1] + "\" does not exist.");
494 break;
495 }
496 else
497 {
498 m_console.Notice(n + " GET " + cmdparams[1] + " " + cmdparams[2] + ": " +
499 c.GetString(cmdparams[2]));
500 }
501 }
328 502
329 m_log.Info("[ Login ] Login are disabled ");
330 else
331 m_log.Info("[ Login ] Login are enabled");
332 break;
333 case "create-region":
334 if (cmdparams.Length < 2)
335 {
336 m_console.Error("Usage: create-region <region name> <region_file.xml>");
337 break; 503 break;
338 } 504 case "save":
505 m_console.Notice("Saving configuration file: " + Application.iniFilePath);
506 m_config.Save(Application.iniFilePath);
507 break;
508 }
509 }
510 }
339 511
340 string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim(); 512 private void HandleModules(string module, string[] cmd)
341 string regionFile = String.Format("{0}/{1}", regionsDir, cmdparams[1]); 513 {
342 // Allow absolute and relative specifiers 514 List<string> args = new List<string>(cmd);
343 if (cmdparams[1].StartsWith("/") || cmdparams[1].StartsWith("\\") || cmdparams[1].StartsWith("..")) 515 args.RemoveAt(0);
344 regionFile = cmdparams[1]; 516 string[] cmdparams = args.ToArray();
345 517
346 CreateRegion(new RegionInfo(cmdparams[0], regionFile, false, ConfigSource.Source), true); 518 if (cmdparams.Length > 0)
347 break; 519 {
520 switch (cmdparams[0].ToLower())
521 {
522 case "list":
523 foreach (IRegionModule irm in m_moduleLoader.GetLoadedSharedModules)
524 {
525 m_console.Notice("Shared region module: " + irm.Name);
526 }
527 break;
528 case "unload":
529 if (cmdparams.Length > 1)
530 {
531 foreach (IRegionModule rm in new ArrayList(m_moduleLoader.GetLoadedSharedModules))
532 {
533 if (rm.Name.ToLower() == cmdparams[1].ToLower())
534 {
535 m_console.Notice("Unloading module: " + rm.Name);
536 m_moduleLoader.UnloadModule(rm);
537 }
538 }
539 }
540 break;
541 case "load":
542 if (cmdparams.Length > 1)
543 {
544 foreach (Scene s in new ArrayList(m_sceneManager.Scenes))
545 {
348 546
349 case "remove-region": 547 m_console.Notice("Loading module: " + cmdparams[1]);
350 string regRemoveName = CombineParams(cmdparams, 0); 548 m_moduleLoader.LoadRegionModules(cmdparams[1], s);
549 }
550 }
551 break;
552 }
553 }
554 }
351 555
352 Scene removeScene;
353 if (m_sceneManager.TryGetScene(regRemoveName, out removeScene))
354 RemoveRegion(removeScene, false);
355 else
356 m_console.Error("no region with that name");
357 break;
358 556
359 case "delete-region": 557 /// <summary>
360 string regDeleteName = CombineParams(cmdparams, 0); 558 /// Runs commands issued by the server console from the operator
559 /// </summary>
560 /// <param name="command">The first argument of the parameter (the command)</param>
561 /// <param name="cmdparams">Additional arguments passed to the command</param>
562 public void RunCommand(string module, string[] cmdparams)
563 {
564 List<string> args = new List<string>(cmdparams);
565 if (args.Count < 1)
566 return;
361 567
362 Scene killScene; 568 string command = args[0];
363 if (m_sceneManager.TryGetScene(regDeleteName, out killScene)) 569 args.RemoveAt(0);
364 RemoveRegion(killScene, true);
365 else
366 m_console.Error("no region with that name");
367 break;
368 570
369 case "restart": 571 cmdparams = args.ToArray();
370 m_sceneManager.RestartCurrentScene();
371 break;
372 572
373 case "change-region": 573 switch (command)
374 ChangeSelectedRegion(cmdparams); 574 {
375 break; 575 case "command-script":
576 if (cmdparams.Length > 0)
577 {
578 RunCommandScript(cmdparams[0]);
579 }
580 break;
376 581
377 case "export-map": 582 case "backup":
378 if (cmdparams.Length > 0) 583 m_sceneManager.BackupCurrentScene();
379 { 584 break;
380 m_sceneManager.CurrentOrFirstScene.ExportWorldMap(cmdparams[0]);
381 }
382 else
383 {
384 m_sceneManager.CurrentOrFirstScene.ExportWorldMap("exportmap.jpg");
385 }
386 break;
387 585
388 case "config": 586 case "alert":
389 string n = command.ToUpper(); 587 m_sceneManager.HandleAlertCommandOnCurrentScene(cmdparams);
390 if (cmdparams.Length > 0) 588 break;
391 {
392 switch (cmdparams[0].ToLower())
393 {
394 case "set":
395 if (cmdparams.Length < 4)
396 {
397 m_console.Error(n, "SYNTAX: " + n + " SET SECTION KEY VALUE");
398 m_console.Error(n, "EXAMPLE: " + n + " SET ScriptEngine.DotNetEngine NumberOfScriptThreads 5");
399 }
400 else
401 {
402 // IConfig c = DefaultConfig().Configs[cmdparams[1]];
403 // if (c == null)
404 // c = DefaultConfig().AddConfig(cmdparams[1]);
405 IConfig c;
406 IConfigSource source = new IniConfigSource();
407 c = source.AddConfig(cmdparams[1]);
408 if (c != null)
409 {
410 string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3);
411 c.Set(cmdparams[2], _value);
412 m_config.Source.Merge(source);
413
414 m_console.Error(n, n + " " + n + " " + cmdparams[1] + " " + cmdparams[2] + " " +
415 _value);
416 }
417 }
418 break;
419 case "get":
420 if (cmdparams.Length < 3)
421 {
422 m_console.Error(n, "SYNTAX: " + n + " GET SECTION KEY");
423 m_console.Error(n, "EXAMPLE: " + n + " GET ScriptEngine.DotNetEngine NumberOfScriptThreads");
424 }
425 else
426 {
427 IConfig c = m_config.Source.Configs[cmdparams[1]]; // DefaultConfig().Configs[cmdparams[1]];
428 if (c == null)
429 {
430 m_console.Notice(n, "Section \"" + cmdparams[1] + "\" does not exist.");
431 break;
432 }
433 else
434 {
435 m_console.Notice(n + " GET " + cmdparams[1] + " " + cmdparams[2] + ": " +
436 c.GetString(cmdparams[2]));
437 }
438 }
439 589
440 break; 590 case "remove-region":
441 case "save": 591 string regRemoveName = CombineParams(cmdparams, 0);
442 m_console.Notice("Saving configuration file: " + Application.iniFilePath);
443 m_config.Save(Application.iniFilePath);
444 break;
445 }
446 }
447 break;
448 592
449 case "modules": 593 Scene removeScene;
450 if (cmdparams.Length > 0) 594 if (m_sceneManager.TryGetScene(regRemoveName, out removeScene))
451 { 595 RemoveRegion(removeScene, false);
452 switch (cmdparams[0].ToLower()) 596 else
453 { 597 m_console.Error("no region with that name");
454 case "list": 598 break;
455 foreach (IRegionModule irm in m_moduleLoader.GetLoadedSharedModules)
456 {
457 m_console.Notice("Shared region module: " + irm.Name);
458 }
459 break;
460 case "unload":
461 if (cmdparams.Length > 1)
462 {
463 foreach (IRegionModule rm in new ArrayList(m_moduleLoader.GetLoadedSharedModules))
464 {
465 if (rm.Name.ToLower() == cmdparams[1].ToLower())
466 {
467 m_console.Notice("Unloading module: " + rm.Name);
468 m_moduleLoader.UnloadModule(rm);
469 }
470 }
471 }
472 break;
473 case "load":
474 if (cmdparams.Length > 1)
475 {
476 foreach (Scene s in new ArrayList(m_sceneManager.Scenes))
477 {
478 599
479 m_console.Notice("Loading module: " + cmdparams[1]); 600 case "delete-region":
480 m_moduleLoader.LoadRegionModules(cmdparams[1], s); 601 string regDeleteName = CombineParams(cmdparams, 0);
481 }
482 }
483 break;
484 }
485 }
486 602
487 break; 603 Scene killScene;
604 if (m_sceneManager.TryGetScene(regDeleteName, out killScene))
605 RemoveRegion(killScene, true);
606 else
607 m_console.Error("no region with that name");
608 break;
488 609
489 case "Add-InventoryHost": 610 case "restart":
490 if (cmdparams.Length > 0) 611 m_sceneManager.RestartCurrentScene();
491 { 612 break;
492 m_commsManager.AddInventoryService(cmdparams[0]);
493 }
494 break;
495 613
496 case "reset": 614 case "export-map":
497 Reset(cmdparams); 615 if (cmdparams.Length > 0)
498 break; 616 {
499 617 m_sceneManager.CurrentOrFirstScene.ExportWorldMap(cmdparams[0]);
500 case "predecode-j2k": 618 }
501 if (cmdparams.Length > 0) 619 else
502 { 620 {
503 m_sceneManager.CacheJ2kDecode(Convert.ToInt32(cmdparams[0])); 621 m_sceneManager.CurrentOrFirstScene.ExportWorldMap("exportmap.jpg");
504 } 622 }
505 else 623 break;
506 {
507 m_sceneManager.CacheJ2kDecode(1);
508 }
509 break;
510 624
511 default: 625 case "Add-InventoryHost":
512 string[] tmpPluginArgs = new string[cmdparams.Length + 1]; 626 if (cmdparams.Length > 0)
513 cmdparams.CopyTo(tmpPluginArgs, 1); 627 {
514 tmpPluginArgs[0] = command; 628 m_commsManager.AddInventoryService(cmdparams[0]);
629 }
630 break;
515 631
516 m_sceneManager.SendCommandToPluginModules(tmpPluginArgs); 632 case "predecode-j2k":
517 break; 633 if (cmdparams.Length > 0)
634 {
635 m_sceneManager.CacheJ2kDecode(Convert.ToInt32(cmdparams[0]));
636 }
637 else
638 {
639 m_sceneManager.CacheJ2kDecode(1);
640 }
641 break;
518 } 642 }
519 } 643 }
520 644
@@ -522,46 +646,39 @@ namespace OpenSim
522 /// Change the currently selected region. The selected region is that operated upon by single region commands. 646 /// Change the currently selected region. The selected region is that operated upon by single region commands.
523 /// </summary> 647 /// </summary>
524 /// <param name="cmdParams"></param> 648 /// <param name="cmdParams"></param>
525 protected void ChangeSelectedRegion(string[] cmdparams) 649 protected void ChangeSelectedRegion(string module, string[] cmdparams)
526 { 650 {
527 if (cmdparams.Length > 0) 651 if (cmdparams.Length > 2)
528 { 652 {
529 string newRegionName = CombineParams(cmdparams, 0); 653 string newRegionName = CombineParams(cmdparams, 2);
530 654
531 if (!m_sceneManager.TrySetCurrentScene(newRegionName)) 655 if (!m_sceneManager.TrySetCurrentScene(newRegionName))
532 m_console.Error("Couldn't select region " + newRegionName); 656 m_console.Error("Couldn't select region " + newRegionName);
533 } 657 }
534 else 658 else
535 { 659 {
536 m_console.Error("Usage: change-region <region name>"); 660 m_console.Error("Usage: change region <region name>");
537 } 661 }
538 662
539 string regionName = (m_sceneManager.CurrentScene == null ? "root" : m_sceneManager.CurrentScene.RegionInfo.RegionName); 663 string regionName = (m_sceneManager.CurrentScene == null ? "root" : m_sceneManager.CurrentScene.RegionInfo.RegionName);
540 m_console.Notice(String.Format("Currently selected region is {0}", regionName)); 664 m_console.Notice(String.Format("Currently selected region is {0}", regionName));
541 m_console.DefaultPrompt = String.Format("Region ({0}) ", regionName); 665 m_console.DefaultPrompt = String.Format("Region ({0}) ", regionName);
666 m_console.ConsoleScene = m_sceneManager.CurrentScene;
542 } 667 }
543 668
544 /// <summary> 669 /// <summary>
545 /// Execute switch for some of the create commands 670 /// Execute switch for some of the create commands
546 /// </summary> 671 /// </summary>
547 /// <param name="args"></param> 672 /// <param name="args"></param>
548 protected void Create(string[] args) 673 private void HandleCreateUser(string module, string[] cmd)
549 { 674 {
550 if (args.Length == 0) 675 if (ConfigurationSettings.Standalone)
551 return;
552
553 switch (args[0])
554 { 676 {
555 case "user": 677 CreateUser(cmd);
556 if (ConfigurationSettings.Standalone) 678 }
557 { 679 else
558 CreateUser(args); 680 {
559 } 681 m_console.Notice("Create user is not available in grid mode, use the user server.");
560 else
561 {
562 m_console.Notice("Create user is not available in grid mode, use the user server.");
563 }
564 break;
565 } 682 }
566 } 683 }
567 684
@@ -569,30 +686,15 @@ namespace OpenSim
569 /// Execute switch for some of the reset commands 686 /// Execute switch for some of the reset commands
570 /// </summary> 687 /// </summary>
571 /// <param name="args"></param> 688 /// <param name="args"></param>
572 protected void Reset(string[] args) 689 protected void HandleResetUserPassword(string module, string[] cmd)
573 { 690 {
574 if (args.Length == 0) 691 if (ConfigurationSettings.Standalone)
575 return;
576
577 switch (args[0])
578 { 692 {
579 case "user": 693 ResetUserPassword(cmd);
580 694 }
581 switch (args[1]) 695 else
582 { 696 {
583 case "password": 697 m_console.Notice("Reset user password is not available in grid mode, use the user-server.");
584 if (ConfigurationSettings.Standalone)
585 {
586 ResetUserPassword(args);
587 }
588 else
589 {
590 m_console.Notice("Reset user password is not available in grid mode, use the user-server.");
591 }
592 break;
593 }
594
595 break;
596 } 698 }
597 } 699 }
598 700
@@ -600,18 +702,18 @@ namespace OpenSim
600 /// Turn on some debugging values for OpenSim. 702 /// Turn on some debugging values for OpenSim.
601 /// </summary> 703 /// </summary>
602 /// <param name="args"></param> 704 /// <param name="args"></param>
603 protected void Debug(string[] args) 705 protected void Debug(string module, string[] args)
604 { 706 {
605 if (args.Length == 0) 707 if (args.Length == 1)
606 return; 708 return;
607 709
608 switch (args[0]) 710 switch (args[1])
609 { 711 {
610 case "packet": 712 case "packet":
611 if (args.Length > 1) 713 if (args.Length > 2)
612 { 714 {
613 int newDebug; 715 int newDebug;
614 if (int.TryParse(args[1], out newDebug)) 716 if (int.TryParse(args[2], out newDebug))
615 { 717 {
616 m_sceneManager.SetDebugPacketLevelOnCurrentScene(newDebug); 718 m_sceneManager.SetDebugPacketLevelOnCurrentScene(newDebug);
617 } 719 }
@@ -625,17 +727,17 @@ namespace OpenSim
625 break; 727 break;
626 728
627 case "scene": 729 case "scene":
628 if (args.Length == 4) 730 if (args.Length == 5)
629 { 731 {
630 if (m_sceneManager.CurrentScene == null) 732 if (m_sceneManager.CurrentScene == null)
631 { 733 {
632 m_console.Error("CONSOLE", "Please use 'change-region <regioname>' first"); 734 m_console.Notice("Please use 'change region <regioname>' first");
633 } 735 }
634 else 736 else
635 { 737 {
636 bool scriptingOn = !Convert.ToBoolean(args[1]); 738 bool scriptingOn = !Convert.ToBoolean(args[2]);
637 bool collisionsOn = !Convert.ToBoolean(args[2]); 739 bool collisionsOn = !Convert.ToBoolean(args[3]);
638 bool physicsOn = !Convert.ToBoolean(args[3]); 740 bool physicsOn = !Convert.ToBoolean(args[4]);
639 m_sceneManager.CurrentScene.SetSceneCoreDebug(scriptingOn, collisionsOn, physicsOn); 741 m_sceneManager.CurrentScene.SetSceneCoreDebug(scriptingOn, collisionsOn, physicsOn);
640 742
641 m_console.Notice( 743 m_console.Notice(
@@ -658,87 +760,12 @@ namespace OpenSim
658 } 760 }
659 } 761 }
660 762
661 protected override void ShowHelp(string[] helpArgs)
662 {
663 base.ShowHelp(helpArgs);
664
665 if (helpArgs.Length == 0)
666 {
667 m_console.Notice("alert - send alert to a designated user or all users.");
668 m_console.Notice(" alert [First] [Last] [Message] - send an alert to a user. Case sensitive.");
669 m_console.Notice(" alert general [Message] - send an alert to all users.");
670 m_console.Notice("backup - persist simulator objects to the database ahead of the normal schedule.");
671 m_console.Notice("clear-assets - clear the asset cache");
672 m_console.Notice("create-region <name> <regionfile.xml> - create a new region");
673 m_console.Notice("change-region <name> - select the region that single region commands operate upon.");
674 m_console.Notice("command-script [filename] - Execute command in a file.");
675 m_console.Notice("debug - debugging commands");
676 m_console.Notice(" debug packet 0..255 - print incoming/outgoing packets (0=off)");
677 m_console.Notice(" debug scene [scripting] [collision] [physics] - Enable/Disable debug stuff, each can be True/False");
678 m_console.Notice("edit-scale [prim name] [x] [y] [z] - resize given prim");
679 m_console.Notice("export-map [filename] - save image of world map");
680 m_console.Notice("force-update - force an update of prims in the scene");
681 m_console.Notice("restart - disconnects all clients and restarts the sims in the instance.");
682 m_console.Notice("remove-region [name] - remove a region");
683 m_console.Notice("delete-region [name] - delete a region and its associated region file");
684 m_console.Notice("load-xml [filename] - load prims from XML (DEPRECATED)");
685 m_console.Notice("save-xml [filename] - save prims to XML (DEPRECATED)");
686 m_console.Notice("save-xml2 [filename] - save prims to XML using version 2 format");
687 m_console.Notice("load-xml2 [filename] - load prims from XML using version 2 format");
688 m_console.Notice("load-oar [filename] - load an OpenSimulator region archive. This replaces everything in the current region.");
689 m_console.Notice("save-oar [filename] - Save the current region to an OpenSimulator region archive.");
690 m_console.Notice("script - manually trigger scripts? or script commands?");
691 m_console.Notice("show assets - show state of asset cache.");
692 m_console.Notice("show modules - shows info about loaded modules.");
693 m_console.Notice("show queues - show packet queues length for all clients.");
694 m_console.Notice("show regions - show running region information.");
695 m_console.Notice("show users - show info about connected users (only root agents).");
696 m_console.Notice("show users full - show info about connected users (root and child agents).");
697 m_console.Notice("config set section field value - set a config value");
698 m_console.Notice("config get section field - get a config value");
699 m_console.Notice("config save - save OpenSim.ini");
700 m_console.Notice("login-enable - Allows login at sim level");
701 m_console.Notice("login-disable - Disable login at sim level");
702 m_console.Notice("login-status - Show the actual login status");
703 m_console.Notice("predecode-j2k - Precache assets,decode j2k layerdata, First parameter is threads to use");
704 ShowPluginCommandsHelp(CombineParams(helpArgs, 0), m_console);
705
706 if (ConfigurationSettings.Standalone)
707 {
708 m_console.Notice("");
709 m_console.Notice("create user - adds a new user.");
710 m_console.Notice("reset user password - reset a user's password.");
711 }
712 }
713 else
714 {
715 // Messily we want to join all the help params back here
716 //string helpSubject = string.Join(" ", helpArgs);
717
718 // FIXME: Very cheap hack to get transition help working. Will disappear very shortly.
719 if (helpArgs.Length == 1)
720 {
721 ICommander moduleCommander = SceneManager.CurrentOrFirstScene.GetCommander(helpArgs[0]);
722 if (moduleCommander != null)
723 {
724 m_console.Notice(moduleCommander.Help);
725 }
726 }
727 else
728 {
729 ICommand command = SceneManager.CurrentOrFirstScene.GetCommand(helpArgs[1]);
730 if (command != null)
731 {
732 m_console.Notice(command.Help);
733 }
734 }
735 }
736 }
737
738 // see BaseOpenSimServer 763 // see BaseOpenSimServer
739 public override void Show(string[] showParams) 764 private void HandleShow(string mod, string[] cmd)
740 { 765 {
741 base.Show(showParams); 766 List<string> args = new List<string>(cmd);
767 args.RemoveAt(0);
768 string[] showParams = args.ToArray();
742 769
743 switch (showParams[0]) 770 switch (showParams[0])
744 { 771 {
@@ -864,29 +891,29 @@ namespace OpenSim
864 uint regX = 1000; 891 uint regX = 1000;
865 uint regY = 1000; 892 uint regY = 1000;
866 893
867 if (cmdparams.Length < 2) 894 if (cmdparams.Length < 3)
868 firstName = MainConsole.Instance.CmdPrompt("First name", "Default"); 895 firstName = MainConsole.Instance.CmdPrompt("First name", "Default");
869 else firstName = cmdparams[1]; 896 else firstName = cmdparams[2];
870 897
871 if ( cmdparams.Length < 3 ) 898 if ( cmdparams.Length < 4 )
872 lastName = MainConsole.Instance.CmdPrompt("Last name", "User"); 899 lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
873 else lastName = cmdparams[2]; 900 else lastName = cmdparams[3];
874 901
875 if (cmdparams.Length < 4) 902 if (cmdparams.Length < 5)
876 password = MainConsole.Instance.PasswdPrompt("Password"); 903 password = MainConsole.Instance.PasswdPrompt("Password");
877 else password = cmdparams[3]; 904 else password = cmdparams[4];
878 905
879 if ( cmdparams.Length < 5 ) 906 if ( cmdparams.Length < 6 )
880 regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString())); 907 regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString()));
881 else regX = Convert.ToUInt32(cmdparams[4]); 908 else regX = Convert.ToUInt32(cmdparams[5]);
882 909
883 if ( cmdparams.Length < 6 ) 910 if ( cmdparams.Length < 7 )
884 regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString())); 911 regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString()));
885 else regY = Convert.ToUInt32(cmdparams[5]); 912 else regY = Convert.ToUInt32(cmdparams[6]);
886 913
887 if (cmdparams.Length < 7) 914 if (cmdparams.Length < 8)
888 email = MainConsole.Instance.CmdPrompt("Email", ""); 915 email = MainConsole.Instance.CmdPrompt("Email", "");
889 else email = cmdparams[6]; 916 else email = cmdparams[7];
890 917
891 if (null == m_commsManager.UserService.GetUserProfile(firstName, lastName)) 918 if (null == m_commsManager.UserService.GetUserProfile(firstName, lastName))
892 { 919 {
@@ -908,28 +935,40 @@ namespace OpenSim
908 string lastName; 935 string lastName;
909 string newPassword; 936 string newPassword;
910 937
911 if (cmdparams.Length < 3) 938 if (cmdparams.Length < 4)
912 firstName = MainConsole.Instance.CmdPrompt("First name"); 939 firstName = MainConsole.Instance.CmdPrompt("First name");
913 else firstName = cmdparams[2]; 940 else firstName = cmdparams[3];
914 941
915 if ( cmdparams.Length < 4 ) 942 if ( cmdparams.Length < 5 )
916 lastName = MainConsole.Instance.CmdPrompt("Last name"); 943 lastName = MainConsole.Instance.CmdPrompt("Last name");
917 else lastName = cmdparams[3]; 944 else lastName = cmdparams[4];
918 945
919 if ( cmdparams.Length < 5 ) 946 if ( cmdparams.Length < 6 )
920 newPassword = MainConsole.Instance.PasswdPrompt("New password"); 947 newPassword = MainConsole.Instance.PasswdPrompt("New password");
921 else newPassword = cmdparams[4]; 948 else newPassword = cmdparams[5];
922 949
923 m_commsManager.UserAdminService.ResetUserPassword(firstName, lastName, newPassword); 950 m_commsManager.UserAdminService.ResetUserPassword(firstName, lastName, newPassword);
924 } 951 }
925 952
926 protected void SaveXml(string[] cmdparams) 953 protected void SavePrimsXml2(string module, string[] cmdparams)
954 {
955 if (cmdparams.Length > 5)
956 {
957 m_sceneManager.SaveNamedPrimsToXml2(cmdparams[3], cmdparams[4]);
958 }
959 else
960 {
961 m_sceneManager.SaveNamedPrimsToXml2("Primitive", DEFAULT_PRIM_BACKUP_FILENAME);
962 }
963 }
964
965 protected void SaveXml(string module, string[] cmdparams)
927 { 966 {
928 m_log.Error("[CONSOLE]: PLEASE NOTE, save-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use save-xml2, please file a mantis detailing the reason."); 967 m_log.Error("[CONSOLE]: PLEASE NOTE, save-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use save-xml2, please file a mantis detailing the reason.");
929 968
930 if (cmdparams.Length > 0) 969 if (cmdparams.Length > 0)
931 { 970 {
932 m_sceneManager.SaveCurrentSceneToXml(cmdparams[0]); 971 m_sceneManager.SaveCurrentSceneToXml(cmdparams[2]);
933 } 972 }
934 else 973 else
935 { 974 {
@@ -937,30 +976,30 @@ namespace OpenSim
937 } 976 }
938 } 977 }
939 978
940 protected void LoadXml(string[] cmdparams) 979 protected void LoadXml(string module, string[] cmdparams)
941 { 980 {
942 m_log.Error("[CONSOLE]: PLEASE NOTE, load-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use load-xml2, please file a mantis detailing the reason."); 981 m_log.Error("[CONSOLE]: PLEASE NOTE, load-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use load-xml2, please file a mantis detailing the reason.");
943 982
944 Vector3 loadOffset = new Vector3(0, 0, 0); 983 Vector3 loadOffset = new Vector3(0, 0, 0);
945 if (cmdparams.Length > 0) 984 if (cmdparams.Length > 2)
946 { 985 {
947 bool generateNewIDS = false; 986 bool generateNewIDS = false;
948 if (cmdparams.Length > 1) 987 if (cmdparams.Length > 3)
949 { 988 {
950 if (cmdparams[1] == "-newUID") 989 if (cmdparams[3] == "-newUID")
951 { 990 {
952 generateNewIDS = true; 991 generateNewIDS = true;
953 } 992 }
954 if (cmdparams.Length > 2) 993 if (cmdparams.Length > 4)
955 { 994 {
956 loadOffset.X = (float) Convert.ToDecimal(cmdparams[2]); 995 loadOffset.X = (float) Convert.ToDecimal(cmdparams[4]);
957 if (cmdparams.Length > 3) 996 if (cmdparams.Length > 5)
958 { 997 {
959 loadOffset.Y = (float) Convert.ToDecimal(cmdparams[3]); 998 loadOffset.Y = (float) Convert.ToDecimal(cmdparams[5]);
960 } 999 }
961 if (cmdparams.Length > 4) 1000 if (cmdparams.Length > 6)
962 { 1001 {
963 loadOffset.Z = (float) Convert.ToDecimal(cmdparams[4]); 1002 loadOffset.Z = (float) Convert.ToDecimal(cmdparams[6]);
964 } 1003 }
965 m_console.Error("loadOffsets <X,Y,Z> = <" + loadOffset.X + "," + loadOffset.Y + "," + 1004 m_console.Error("loadOffsets <X,Y,Z> = <" + loadOffset.X + "," + loadOffset.Y + "," +
966 loadOffset.Z + ">"); 1005 loadOffset.Z + ">");
@@ -981,11 +1020,11 @@ namespace OpenSim
981 } 1020 }
982 } 1021 }
983 1022
984 protected void SaveXml2(string[] cmdparams) 1023 protected void SaveXml2(string module, string[] cmdparams)
985 { 1024 {
986 if (cmdparams.Length > 0) 1025 if (cmdparams.Length > 2)
987 { 1026 {
988 m_sceneManager.SaveCurrentSceneToXml2(cmdparams[0]); 1027 m_sceneManager.SaveCurrentSceneToXml2(cmdparams[2]);
989 } 1028 }
990 else 1029 else
991 { 1030 {
@@ -993,11 +1032,11 @@ namespace OpenSim
993 } 1032 }
994 } 1033 }
995 1034
996 protected void LoadXml2(string[] cmdparams) 1035 protected void LoadXml2(string module, string[] cmdparams)
997 { 1036 {
998 if (cmdparams.Length > 0) 1037 if (cmdparams.Length > 2)
999 { 1038 {
1000 m_sceneManager.LoadCurrentSceneFromXml2(cmdparams[0]); 1039 m_sceneManager.LoadCurrentSceneFromXml2(cmdparams[2]);
1001 } 1040 }
1002 else 1041 else
1003 { 1042 {
@@ -1007,7 +1046,7 @@ namespace OpenSim
1007 } 1046 }
1008 catch 1047 catch
1009 { 1048 {
1010 m_console.Error("Default xml not found. Usage: load-xml2 <filename>"); 1049 m_console.Error("Default xml not found. Usage: load xml2 <filename>");
1011 } 1050 }
1012 } 1051 }
1013 } 1052 }
@@ -1016,11 +1055,11 @@ namespace OpenSim
1016 /// Load a whole region from an opensim archive. 1055 /// Load a whole region from an opensim archive.
1017 /// </summary> 1056 /// </summary>
1018 /// <param name="cmdparams"></param> 1057 /// <param name="cmdparams"></param>
1019 protected void LoadOar(string[] cmdparams) 1058 protected void LoadOar(string module, string[] cmdparams)
1020 { 1059 {
1021 if (cmdparams.Length > 0) 1060 if (cmdparams.Length > 2)
1022 { 1061 {
1023 m_sceneManager.LoadArchiveToCurrentScene(cmdparams[0]); 1062 m_sceneManager.LoadArchiveToCurrentScene(cmdparams[2]);
1024 } 1063 }
1025 else 1064 else
1026 { 1065 {
@@ -1039,11 +1078,11 @@ namespace OpenSim
1039 /// Save a region to a file, including all the assets needed to restore it. 1078 /// Save a region to a file, including all the assets needed to restore it.
1040 /// </summary> 1079 /// </summary>
1041 /// <param name="cmdparams"></param> 1080 /// <param name="cmdparams"></param>
1042 protected void SaveOar(string[] cmdparams) 1081 protected void SaveOar(string module, string[] cmdparams)
1043 { 1082 {
1044 if (cmdparams.Length > 0) 1083 if (cmdparams.Length > 2)
1045 { 1084 {
1046 m_sceneManager.SaveCurrentSceneToArchive(cmdparams[0]); 1085 m_sceneManager.SaveCurrentSceneToArchive(cmdparams[2]);
1047 } 1086 }
1048 else 1087 else
1049 { 1088 {
@@ -1055,19 +1094,19 @@ namespace OpenSim
1055 /// Load inventory from an inventory file archive 1094 /// Load inventory from an inventory file archive
1056 /// </summary> 1095 /// </summary>
1057 /// <param name="cmdparams"></param> 1096 /// <param name="cmdparams"></param>
1058 protected void LoadInv(string[] cmdparams) 1097 protected void LoadInv(string module, string[] cmdparams)
1059 { 1098 {
1060 m_log.Error("[CONSOLE]: This command has not yet been implemented!"); 1099 m_log.Error("[CONSOLE]: This command has not yet been implemented!");
1061 if (cmdparams.Length < 3) 1100 if (cmdparams.Length < 5)
1062 { 1101 {
1063 m_log.Error("[CONSOLE]: usage is load-inv <first name> <last name> <inventory path> [<load file path>]"); 1102 m_log.Error("[CONSOLE]: usage is load-inv <first name> <last name> <inventory path> [<load file path>]");
1064 return; 1103 return;
1065 } 1104 }
1066 1105
1067 string firstName = cmdparams[0]; 1106 string firstName = cmdparams[2];
1068 string lastName = cmdparams[1]; 1107 string lastName = cmdparams[3];
1069 string invPath = cmdparams[2]; 1108 string invPath = cmdparams[4];
1070 string loadPath = (cmdparams.Length > 3 ? cmdparams[3] : DEFAULT_INV_BACKUP_FILENAME); 1109 string loadPath = (cmdparams.Length > 5 ? cmdparams[5] : DEFAULT_INV_BACKUP_FILENAME);
1071 1110
1072 new InventoryArchiveReadRequest( 1111 new InventoryArchiveReadRequest(
1073 m_sceneManager.CurrentOrFirstScene, m_commsManager).execute( 1112 m_sceneManager.CurrentOrFirstScene, m_commsManager).execute(
@@ -1078,19 +1117,19 @@ namespace OpenSim
1078 /// Save inventory to a file archive 1117 /// Save inventory to a file archive
1079 /// </summary> 1118 /// </summary>
1080 /// <param name="cmdparams"></param> 1119 /// <param name="cmdparams"></param>
1081 protected void SaveInv(string[] cmdparams) 1120 protected void SaveInv(string module, string[] cmdparams)
1082 { 1121 {
1083 m_log.Error("[CONSOLE]: This command has not yet been implemented!"); 1122 m_log.Error("[CONSOLE]: This command has not yet been implemented!");
1084 if (cmdparams.Length < 3) 1123 if (cmdparams.Length < 5)
1085 { 1124 {
1086 m_log.Error("[CONSOLE]: usage is save-inv <first name> <last name> <inventory path> [<save file path>]"); 1125 m_log.Error("[CONSOLE]: usage is save-inv <first name> <last name> <inventory path> [<save file path>]");
1087 return; 1126 return;
1088 } 1127 }
1089 1128
1090 string firstName = cmdparams[0]; 1129 string firstName = cmdparams[2];
1091 string lastName = cmdparams[1]; 1130 string lastName = cmdparams[3];
1092 string invPath = cmdparams[2]; 1131 string invPath = cmdparams[4];
1093 string savePath = (cmdparams.Length > 3 ? cmdparams[3] : DEFAULT_INV_BACKUP_FILENAME); 1132 string savePath = (cmdparams.Length > 5 ? cmdparams[5] : DEFAULT_INV_BACKUP_FILENAME);
1094 1133
1095 new InventoryArchiveWriteRequest( 1134 new InventoryArchiveWriteRequest(
1096 m_sceneManager.CurrentOrFirstScene,m_commsManager).execute( 1135 m_sceneManager.CurrentOrFirstScene,m_commsManager).execute(
@@ -1108,62 +1147,6 @@ namespace OpenSim
1108 return result; 1147 return result;
1109 } 1148 }
1110 1149
1111 /// <summary>
1112 /// Runs the best matching plugin command
1113 /// </summary>
1114 /// <param name="cmd"></param>
1115 /// <param name="withParams"></param>
1116 /// <returns>true if a match was found, false otherwise</returns>
1117 public bool RunPluginCommands(string cmd, string[] withParams)
1118 {
1119 ConsolePluginCommand bestMatch = null;
1120 int bestLength = 0;
1121 String cmdWithParams = cmd + " " + String.Join(" ",withParams);
1122
1123 foreach (ConsolePluginCommand cmdinfo in m_PluginCommandInfos)
1124 {
1125 int matchLen = cmdinfo.matchLength(cmdWithParams);
1126 if (matchLen > bestLength)
1127 {
1128 bestMatch = cmdinfo;
1129 bestLength = matchLen;
1130 }
1131 }
1132
1133 if (bestMatch == null) return false;
1134 bestMatch.Run(cmd,withParams);//.Substring(bestLength));
1135 return true;
1136 }
1137
1138 /// <summary>
1139 /// Show the matching plugins command help
1140 /// </summary>
1141 public void ShowPluginCommandsHelp(string cmdWithParams, ConsoleBase console)
1142 {
1143 foreach (ConsolePluginCommand cmdinfo in m_PluginCommandInfos)
1144 {
1145 if (cmdinfo.IsHelpfull(cmdWithParams))
1146 {
1147 cmdinfo.ShowHelp(console);
1148 }
1149 }
1150 }
1151
1152 /// <summary>
1153 /// Registers a new console plugin command
1154 /// </summary>
1155 public static void RegisterCmd(string cmd, ConsoleCommand deligate, string help)
1156 {
1157 RegisterConsolePluginCommand(new ConsolePluginCommand(cmd, deligate, help));
1158 }
1159
1160 /// <summary>
1161 /// Registers a new console plugin command
1162 /// </summary>
1163 public static void RegisterConsolePluginCommand(ConsolePluginCommand pluginCommand)
1164 {
1165 m_PluginCommandInfos.Add(pluginCommand);
1166 }
1167 #endregion 1150 #endregion
1168 } 1151 }
1169} 1152}