diff options
author | Justin Clark-Casey (justincc) | 2011-10-31 23:22:55 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-10-31 23:22:55 +0000 |
commit | b951c7fb1e5a284a9bf95054cb168e64ebfe717d (patch) | |
tree | 229a10fb05ac5ee8e4c4f463e253f55320e108c6 /OpenSim/Tools/pCampBot | |
parent | Remove OpenSim.TestSuite (diff) | |
download | opensim-SC_OLD-b951c7fb1e5a284a9bf95054cb168e64ebfe717d.zip opensim-SC_OLD-b951c7fb1e5a284a9bf95054cb168e64ebfe717d.tar.gz opensim-SC_OLD-b951c7fb1e5a284a9bf95054cb168e64ebfe717d.tar.bz2 opensim-SC_OLD-b951c7fb1e5a284a9bf95054cb168e64ebfe717d.tar.xz |
Make bots share a cache so that asset downloads attempts are only made once instead of once for each bot
Diffstat (limited to 'OpenSim/Tools/pCampBot')
-rw-r--r-- | OpenSim/Tools/pCampBot/BotManager.cs | 15 | ||||
-rw-r--r-- | OpenSim/Tools/pCampBot/PhysicsBot.cs | 29 |
2 files changed, 24 insertions, 20 deletions
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index a4b7f16..03bb820 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs | |||
@@ -53,13 +53,20 @@ namespace pCampBot | |||
53 | protected bool m_verbose = true; | 53 | protected bool m_verbose = true; |
54 | protected Random somthing = new Random(Environment.TickCount); | 54 | protected Random somthing = new Random(Environment.TickCount); |
55 | protected int numbots = 0; | 55 | protected int numbots = 0; |
56 | private IConfig Config; | 56 | public IConfig Config { get; private set; } |
57 | |||
58 | /// <summary> | ||
59 | /// Track the assets we have and have not received so we don't endlessly repeat requests. | ||
60 | /// </summary> | ||
61 | public Dictionary<UUID, bool> AssetsReceived { get; private set; } | ||
57 | 62 | ||
58 | /// <summary> | 63 | /// <summary> |
59 | /// Constructor Creates MainConsole.Instance to take commands and provide the place to write data | 64 | /// Constructor Creates MainConsole.Instance to take commands and provide the place to write data |
60 | /// </summary> | 65 | /// </summary> |
61 | public BotManager() | 66 | public BotManager() |
62 | { | 67 | { |
68 | AssetsReceived = new Dictionary<UUID, bool>(); | ||
69 | |||
63 | m_console = CreateConsole(); | 70 | m_console = CreateConsole(); |
64 | MainConsole.Instance = m_console; | 71 | MainConsole.Instance = m_console; |
65 | 72 | ||
@@ -113,7 +120,7 @@ namespace pCampBot | |||
113 | for (int i = 0; i < botcount; i++) | 120 | for (int i = 0; i < botcount; i++) |
114 | { | 121 | { |
115 | string lastName = string.Format("{0}_{1}", lastNameStem, i); | 122 | string lastName = string.Format("{0}_{1}", lastNameStem, i); |
116 | startupBot(i, cs, firstName, lastName, password, loginUri); | 123 | startupBot(i, this, firstName, lastName, password, loginUri); |
117 | } | 124 | } |
118 | } | 125 | } |
119 | 126 | ||
@@ -146,9 +153,9 @@ namespace pCampBot | |||
146 | /// <param name="lastName">Last name</param> | 153 | /// <param name="lastName">Last name</param> |
147 | /// <param name="password">Password</param> | 154 | /// <param name="password">Password</param> |
148 | /// <param name="loginUri">Login URI</param> | 155 | /// <param name="loginUri">Login URI</param> |
149 | public void startupBot(int pos, IConfig cs, string firstName, string lastName, string password, string loginUri) | 156 | public void startupBot(int pos, BotManager bm, string firstName, string lastName, string password, string loginUri) |
150 | { | 157 | { |
151 | PhysicsBot pb = new PhysicsBot(cs, firstName, lastName, password, loginUri); | 158 | PhysicsBot pb = new PhysicsBot(bm, firstName, lastName, password, loginUri); |
152 | 159 | ||
153 | pb.OnConnected += handlebotEvent; | 160 | pb.OnConnected += handlebotEvent; |
154 | pb.OnDisconnected += handlebotEvent; | 161 | pb.OnDisconnected += handlebotEvent; |
diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs index 0c399e3..2070bfd 100644 --- a/OpenSim/Tools/pCampBot/PhysicsBot.cs +++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs | |||
@@ -47,7 +47,9 @@ namespace pCampBot | |||
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 48 | ||
49 | public delegate void AnEvent(PhysicsBot callbot, EventType someevent); // event delegate for bot events | 49 | public delegate void AnEvent(PhysicsBot callbot, EventType someevent); // event delegate for bot events |
50 | public IConfig startupConfig; // bot config, passed from BotManager | 50 | |
51 | public BotManager BotManager { get; private set; } | ||
52 | private IConfig startupConfig; // bot config, passed from BotManager | ||
51 | 53 | ||
52 | public string FirstName { get; private set; } | 54 | public string FirstName { get; private set; } |
53 | public string LastName { get; private set; } | 55 | public string LastName { get; private set; } |
@@ -60,11 +62,6 @@ namespace pCampBot | |||
60 | public event AnEvent OnConnected; | 62 | public event AnEvent OnConnected; |
61 | public event AnEvent OnDisconnected; | 63 | public event AnEvent OnDisconnected; |
62 | 64 | ||
63 | /// <summary> | ||
64 | /// Track the assets we have and have not received so we don't endlessly repeat requests. | ||
65 | /// </summary> | ||
66 | public Dictionary<UUID, bool> AssetsReceived { get; private set; } | ||
67 | |||
68 | protected Timer m_action; // Action Timer | 65 | protected Timer m_action; // Action Timer |
69 | protected List<uint> objectIDs = new List<uint>(); | 66 | protected List<uint> objectIDs = new List<uint>(); |
70 | 67 | ||
@@ -80,23 +77,23 @@ namespace pCampBot | |||
80 | /// <summary> | 77 | /// <summary> |
81 | /// Constructor | 78 | /// Constructor |
82 | /// </summary> | 79 | /// </summary> |
83 | /// <param name="bsconfig"></param> | 80 | /// <param name="bm"></param> |
84 | /// <param name="firstName"></param> | 81 | /// <param name="firstName"></param> |
85 | /// <param name="lastName"></param> | 82 | /// <param name="lastName"></param> |
86 | /// <param name="password"></param> | 83 | /// <param name="password"></param> |
87 | /// <param name="loginUri"></param> | 84 | /// <param name="loginUri"></param> |
88 | public PhysicsBot(IConfig bsconfig, string firstName, string lastName, string password, string loginUri) | 85 | public PhysicsBot(BotManager bm, string firstName, string lastName, string password, string loginUri) |
89 | { | 86 | { |
90 | FirstName = firstName; | 87 | FirstName = firstName; |
91 | LastName = lastName; | 88 | LastName = lastName; |
92 | Name = string.Format("{0} {1}", FirstName, LastName); | 89 | Name = string.Format("{0} {1}", FirstName, LastName); |
93 | Password = password; | 90 | Password = password; |
94 | LoginUri = loginUri; | 91 | LoginUri = loginUri; |
95 | startupConfig = bsconfig; | 92 | |
93 | BotManager = bm; | ||
94 | startupConfig = bm.Config; | ||
96 | readconfig(); | 95 | readconfig(); |
97 | talkarray = readexcuses(); | 96 | talkarray = readexcuses(); |
98 | |||
99 | AssetsReceived = new Dictionary<UUID, bool>(); | ||
100 | } | 97 | } |
101 | 98 | ||
102 | //We do our actions here. This is where one would | 99 | //We do our actions here. This is where one would |
@@ -428,13 +425,13 @@ namespace pCampBot | |||
428 | 425 | ||
429 | private void GetTexture(UUID textureID) | 426 | private void GetTexture(UUID textureID) |
430 | { | 427 | { |
431 | lock (AssetsReceived) | 428 | lock (BotManager.AssetsReceived) |
432 | { | 429 | { |
433 | // Don't request assets more than once. | 430 | // Don't request assets more than once. |
434 | if (AssetsReceived.ContainsKey(textureID)) | 431 | if (BotManager.AssetsReceived.ContainsKey(textureID)) |
435 | return; | 432 | return; |
436 | 433 | ||
437 | AssetsReceived[textureID] = false; | 434 | BotManager.AssetsReceived[textureID] = false; |
438 | client.Assets.RequestImage(textureID, ImageType.Normal, Asset_TextureCallback_Texture); | 435 | client.Assets.RequestImage(textureID, ImageType.Normal, Asset_TextureCallback_Texture); |
439 | } | 436 | } |
440 | } | 437 | } |
@@ -447,8 +444,8 @@ namespace pCampBot | |||
447 | 444 | ||
448 | public void Asset_ReceivedCallback(AssetDownload transfer, Asset asset) | 445 | public void Asset_ReceivedCallback(AssetDownload transfer, Asset asset) |
449 | { | 446 | { |
450 | lock (AssetsReceived) | 447 | lock (BotManager.AssetsReceived) |
451 | AssetsReceived[asset.AssetID] = true; | 448 | BotManager.AssetsReceived[asset.AssetID] = true; |
452 | 449 | ||
453 | // if (wear == "save") | 450 | // if (wear == "save") |
454 | // { | 451 | // { |