opensim-development – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | eva | 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 | |||
28 | using System; |
||
29 | using System.IO; |
||
30 | using System.Reflection; |
||
31 | using System.Threading; |
||
32 | using log4net; |
||
33 | using log4net.Config; |
||
34 | using Nini.Config; |
||
35 | using OpenSim.Framework; |
||
36 | using OpenSim.Framework.Console; |
||
37 | |||
38 | namespace pCampBot |
||
39 | { |
||
40 | /// <summary> |
||
41 | /// Event Types from the BOT. Add new events here |
||
42 | /// </summary> |
||
43 | public enum EventType:int |
||
44 | { |
||
45 | NONE = 0, |
||
46 | CONNECTED = 1, |
||
47 | DISCONNECTED = 2 |
||
48 | } |
||
49 | |||
50 | public class pCampBot |
||
51 | { |
||
52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
||
53 | |||
54 | public const string ConfigFileName = "pCampBot.ini"; |
||
55 | |||
56 | [STAThread] |
||
57 | public static void Main(string[] args) |
||
58 | { |
||
59 | XmlConfigurator.Configure(); |
||
60 | |||
61 | IConfig commandLineConfig = ParseConfig(args); |
||
62 | if (commandLineConfig.Get("help") != null || commandLineConfig.Get("loginuri") == null) |
||
63 | { |
||
64 | Help(); |
||
65 | } |
||
66 | else if ( |
||
67 | commandLineConfig.Get("firstname") == null |
||
68 | || commandLineConfig.Get("lastname") == null |
||
69 | || commandLineConfig.Get("password") == null) |
||
70 | { |
||
71 | Console.WriteLine("ERROR: You must supply a firstname, lastname and password for the bots."); |
||
72 | } |
||
73 | else |
||
74 | { |
||
75 | BotManager bm = new BotManager(); |
||
76 | |||
77 | string iniFilePath = Path.GetFullPath(Path.Combine(Util.configDir(), ConfigFileName)); |
||
78 | |||
79 | if (File.Exists(iniFilePath)) |
||
80 | { |
||
81 | m_log.InfoFormat("[PCAMPBOT]: Reading configuration settings from {0}", iniFilePath); |
||
82 | |||
83 | IConfigSource configSource = new IniConfigSource(iniFilePath); |
||
84 | |||
85 | IConfig botManagerConfig = configSource.Configs["BotManager"]; |
||
86 | |||
87 | if (botManagerConfig != null) |
||
88 | { |
||
89 | bm.LoginDelay = botManagerConfig.GetInt("LoginDelay", bm.LoginDelay); |
||
90 | } |
||
91 | |||
92 | IConfig botConfig = configSource.Configs["Bot"]; |
||
93 | |||
94 | if (botConfig != null) |
||
95 | { |
||
96 | bm.InitBotSendAgentUpdates |
||
97 | = botConfig.GetBoolean("SendAgentUpdates", bm.InitBotSendAgentUpdates); |
||
98 | bm.InitBotRequestObjectTextures |
||
99 | = botConfig.GetBoolean("RequestObjectTextures", bm.InitBotRequestObjectTextures); |
||
100 | } |
||
101 | } |
||
102 | |||
103 | int botcount = commandLineConfig.GetInt("botcount", 1); |
||
104 | bool startConnected = commandLineConfig.Get("connect") != null; |
||
105 | |||
106 | bm.CreateBots(botcount, commandLineConfig); |
||
107 | |||
108 | if (startConnected) |
||
109 | bm.ConnectBots(botcount); |
||
110 | |||
111 | while (true) |
||
112 | { |
||
113 | try |
||
114 | { |
||
115 | MainConsole.Instance.Prompt(); |
||
116 | } |
||
117 | catch (Exception e) |
||
118 | { |
||
119 | m_log.ErrorFormat("Command error: {0}", e); |
||
120 | } |
||
121 | } |
||
122 | } |
||
123 | } |
||
124 | |||
125 | private static IConfig ParseConfig(String[] args) |
||
126 | { |
||
127 | //Set up our nifty config.. thanks to nini |
||
128 | ArgvConfigSource cs = new ArgvConfigSource(args); |
||
129 | |||
130 | cs.AddSwitch("Startup", "connect", "c"); |
||
131 | cs.AddSwitch("Startup", "botcount", "n"); |
||
132 | cs.AddSwitch("Startup", "from", "f"); |
||
133 | cs.AddSwitch("Startup", "loginuri", "l"); |
||
134 | cs.AddSwitch("Startup", "start", "s"); |
||
135 | cs.AddSwitch("Startup", "firstname"); |
||
136 | cs.AddSwitch("Startup", "lastname"); |
||
137 | cs.AddSwitch("Startup", "password"); |
||
138 | cs.AddSwitch("Startup", "behaviours", "b"); |
||
139 | cs.AddSwitch("Startup", "help", "h"); |
||
140 | cs.AddSwitch("Startup", "wear"); |
||
141 | |||
142 | IConfig ol = cs.Configs["Startup"]; |
||
143 | return ol; |
||
144 | } |
||
145 | |||
146 | private static void Help() |
||
147 | { |
||
148 | // Added the wear command. This allows the bot to wear real clothes instead of default locked ones. |
||
149 | // You can either say no, to not load anything, yes, to load one of the default wearables, a folder |
||
150 | // name, to load an specific folder, or save, to save an avatar with some already existing wearables |
||
151 | // worn to the folder MyAppearance/FirstName_LastName, and the load it. |
||
152 | |||
153 | Console.WriteLine( |
||
154 | "Usage: pCampBot -loginuri <loginuri> -firstname <first-name> -lastname <last-name> -password <password> [OPTIONS]\n" |
||
155 | + "Spawns a set of bots to test an OpenSim region\n\n" |
||
156 | + " -l, -loginuri loginuri for grid/standalone (required)\n" |
||
157 | + " -s, -start start location for bots (default: last) (optional). Can be \"last\", \"home\" or a specific location with or without co-ords (e.g. \"region1\" or \"region2/50/30/90\"\n" |
||
158 | + " -firstname first name for the bots (required)\n" |
||
159 | + " -lastname lastname for the bots (required). Each lastname will have _<bot-number> appended, e.g. Ima Bot_0\n" |
||
160 | + " -password password for the bots (required)\n" |
||
161 | + " -n, -botcount number of bots to start (default: 1) (optional)\n" |
||
162 | + " -f, -from starting number for login bot names, e.g. 25 will login Ima Bot_25, Ima Bot_26, etc. (default: 0) (optional)\n" |
||
163 | + " -c, -connect connect all bots at startup (optional)\n" |
||
164 | + " -b, behaviours behaviours for bots. Comma separated, e.g. p,g (default: p) (optional)\n" |
||
165 | + " current options are:\n" |
||
166 | + " p (physics - bots constantly move and jump around)\n" |
||
167 | + " g (grab - bots randomly click prims whether set clickable or not)\n" |
||
168 | + " n (none - bots do nothing)\n" |
||
169 | + " t (teleport - bots regularly teleport between regions on the grid)\n" |
||
170 | // " c (cross)\n" + |
||
171 | + " -wear folder from which to load appearance data, \"no\" if there is no such folder (default: no) (optional)\n" |
||
172 | + " -h, -help show this message.\n"); |
||
173 | } |
||
174 | } |
||
175 | } |