fix(companions): reuse offline bot pool before spawning and preserve AutoLogin.MaxCount

This commit is contained in:
Дмитрий committed 2026-11-18 10:38:31 +05:00
1 parent 7cdf854eb0
commit 74473471db
2 files changed
+55 -17

No files matched your search

+25
View File
@@ -249,6 +249,17 @@ impl Ra {
Ok(out.lines().last().unwrap_or("").to_string())
}
/// Log in up to `count` existing offline bots without creating new characters.
pub fn login_offline_bots(&mut self, count: u32) -> Result<String> {
if !(1..=5000).contains(&count) {
return Err(Error::Invalid(
"Choose between 1 and 5000 companions.".into(),
));
}
let out = self.command(&format!("botcmd loginall {count}"))?;
Ok(out.lines().last().unwrap_or("").to_string())
}
/// Set a new password for an existing account.
pub fn set_account_password(&mut self, name: &str, password: &str) -> Result<()> {
validate_account(name, password)?;
@@ -547,6 +558,20 @@ AC>";
assert_eq!(h.join().unwrap()[2], "botcmd spawnleveled 50");
}
#[test]
fn login_offline_bots_sends_count() {
let _lock = serial();
let (port, h) = fake_ra("BotMgr: queued 500 offline bot(s) for login.");
let mut ra = Ra::connect_to(port, "u", "p").unwrap();
assert_eq!(
ra.login_offline_bots(500).unwrap(),
"BotMgr: queued 500 offline bot(s) for login."
);
assert!(ra.login_offline_bots(0).is_err() && ra.login_offline_bots(6000).is_err());
drop(ra);
assert_eq!(h.join().unwrap()[2], "botcmd loginall 500");
}
#[test]
fn duplicate_account_and_input_validation() {
let _lock = serial();