diff options
Diffstat (limited to 'OpenSim/Tools/pCampBot/pCampBot.cs')
-rw-r--r-- | OpenSim/Tools/pCampBot/pCampBot.cs | 89 |
1 files changed, 65 insertions, 24 deletions
diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs index 9e82577..1fb0e03 100644 --- a/OpenSim/Tools/pCampBot/pCampBot.cs +++ b/OpenSim/Tools/pCampBot/pCampBot.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | ||
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using System.Threading; | 31 | using System.Threading; |
31 | using log4net; | 32 | using log4net; |
@@ -50,30 +51,62 @@ namespace pCampBot | |||
50 | { | 51 | { |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | 53 | ||
54 | public const string ConfigFileName = "pCampBot.ini"; | ||
55 | |||
53 | [STAThread] | 56 | [STAThread] |
54 | public static void Main(string[] args) | 57 | public static void Main(string[] args) |
55 | { | 58 | { |
56 | XmlConfigurator.Configure(); | 59 | XmlConfigurator.Configure(); |
57 | 60 | ||
58 | IConfig config = ParseConfig(args); | 61 | IConfig commandLineConfig = ParseConfig(args); |
59 | if (config.Get("help") != null || config.Get("loginuri") == null) | 62 | if (commandLineConfig.Get("help") != null || commandLineConfig.Get("loginuri") == null) |
60 | { | 63 | { |
61 | Help(); | 64 | Help(); |
62 | } | 65 | } |
63 | else if (config.Get("firstname") == null || config.Get("lastname") == null || config.Get("password") == null) | 66 | else if ( |
67 | commandLineConfig.Get("firstname") == null | ||
68 | || commandLineConfig.Get("lastname") == null | ||
69 | || commandLineConfig.Get("password") == null) | ||
64 | { | 70 | { |
65 | Console.WriteLine("ERROR: You must supply a firstname, lastname and password for the bots."); | 71 | Console.WriteLine("ERROR: You must supply a firstname, lastname and password for the bots."); |
66 | } | 72 | } |
67 | else | 73 | else |
68 | { | 74 | { |
69 | int botcount = config.GetInt("botcount", 1); | ||
70 | |||
71 | BotManager bm = new BotManager(); | 75 | BotManager bm = new BotManager(); |
72 | 76 | ||
73 | //startup specified number of bots. 1 is the default | 77 | string iniFilePath = Path.GetFullPath(Path.Combine(Util.configDir(), ConfigFileName)); |
74 | Thread startBotThread = new Thread(o => bm.dobotStartup(botcount, config)); | 78 | |
75 | startBotThread.Name = "Initial start bots thread"; | 79 | if (File.Exists(iniFilePath)) |
76 | startBotThread.Start(); | 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); | ||
77 | 110 | ||
78 | while (true) | 111 | while (true) |
79 | { | 112 | { |
@@ -94,8 +127,11 @@ namespace pCampBot | |||
94 | //Set up our nifty config.. thanks to nini | 127 | //Set up our nifty config.. thanks to nini |
95 | ArgvConfigSource cs = new ArgvConfigSource(args); | 128 | ArgvConfigSource cs = new ArgvConfigSource(args); |
96 | 129 | ||
130 | cs.AddSwitch("Startup", "connect", "c"); | ||
97 | cs.AddSwitch("Startup", "botcount", "n"); | 131 | cs.AddSwitch("Startup", "botcount", "n"); |
132 | cs.AddSwitch("Startup", "from", "f"); | ||
98 | cs.AddSwitch("Startup", "loginuri", "l"); | 133 | cs.AddSwitch("Startup", "loginuri", "l"); |
134 | cs.AddSwitch("Startup", "start", "s"); | ||
99 | cs.AddSwitch("Startup", "firstname"); | 135 | cs.AddSwitch("Startup", "firstname"); |
100 | cs.AddSwitch("Startup", "lastname"); | 136 | cs.AddSwitch("Startup", "lastname"); |
101 | cs.AddSwitch("Startup", "password"); | 137 | cs.AddSwitch("Startup", "password"); |
@@ -113,22 +149,27 @@ namespace pCampBot | |||
113 | // You can either say no, to not load anything, yes, to load one of the default wearables, a folder | 149 | // You can either say no, to not load anything, yes, to load one of the default wearables, a folder |
114 | // name, to load an specific folder, or save, to save an avatar with some already existing wearables | 150 | // name, to load an specific folder, or save, to save an avatar with some already existing wearables |
115 | // worn to the folder MyAppearance/FirstName_LastName, and the load it. | 151 | // worn to the folder MyAppearance/FirstName_LastName, and the load it. |
152 | |||
116 | Console.WriteLine( | 153 | Console.WriteLine( |
117 | "usage: pCampBot <-loginuri loginuri> [OPTIONS]\n" + | 154 | "Usage: pCampBot -loginuri <loginuri> -firstname <first-name> -lastname <last-name> -password <password> [OPTIONS]\n" |
118 | "Spawns a set of bots to test an OpenSim region\n\n" + | 155 | + "Spawns a set of bots to test an OpenSim region\n\n" |
119 | " -l, -loginuri loginuri for sim to log into (required)\n" + | 156 | + " -l, -loginuri loginuri for grid/standalone (required)\n" |
120 | " -n, -botcount number of bots to start (default: 1)\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" |
121 | " -firstname first name for the bots\n" + | 158 | + " -firstname first name for the bots (required)\n" |
122 | " -lastname lastname for the bots. Each lastname will have _<bot-number> appended, e.g. Ima Bot_0\n" + | 159 | + " -lastname lastname for the bots (required). Each lastname will have _<bot-number> appended, e.g. Ima Bot_0\n" |
123 | " -password password for the bots\n" + | 160 | + " -password password for the bots (required)\n" |
124 | " -b, behaviours behaviours for bots. Comma separated, e.g. p,g. Default is p\n" + | 161 | + " -n, -botcount number of bots to start (default: 1) (optional)\n" |
125 | " current options are:\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" |
126 | " p (physics)\n" + | 163 | + " -c, -connect connect all bots at startup (optional)\n" |
127 | " g (grab)\n" + | 164 | + " -b, behaviours behaviours for bots. Comma separated, e.g. p,g (default: p) (optional)\n" |
128 | " t (teleport)\n" + | 165 | + " current options are:\n" |
129 | // " c (cross)" + | 166 | + " p (physics - bots constantly move and jump around)\n" |
130 | " -wear set appearance folder to load from (default: no)\n" + | 167 | + " g (grab - bots randomly click prims whether set clickable or not)\n" |
131 | " -h, -help show this message"); | 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"); | ||
132 | } | 173 | } |
133 | } | 174 | } |
134 | } | 175 | } |