mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-25 11:25:56 +00:00
Merge Manager 0.9.18 into the Modules Preview line
Preview 0.9.18: Custom Races client 2.0.3, Playerbot Characters settings, companion reuse, the Settings server card, and the two preview notes with their translations. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
8476f4261d
38 files changed
+8855
-87
No files matched your search
+67
-11
@@ -1913,6 +1913,40 @@ async fn module_save_settings(
|
||||
.await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn pbc_connection(
|
||||
state: State<'_, AppState>,
|
||||
id: String,
|
||||
) -> std::result::Result<coa_core::modules::pbc::Setup, UiError> {
|
||||
let root = path_of(&state, &id)?;
|
||||
blocking(move || coa_core::modules::pbc::load(&root)).await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn pbc_list_models(
|
||||
state: State<'_, AppState>,
|
||||
id: String,
|
||||
request: coa_core::modules::pbc::models::Request,
|
||||
) -> std::result::Result<Vec<coa_core::modules::pbc::models::Model>, UiError> {
|
||||
let root = path_of(&state, &id)?;
|
||||
blocking(move || coa_core::modules::pbc::models::list(&root, request)).await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn pbc_save_connection(
|
||||
state: State<'_, AppState>,
|
||||
id: String,
|
||||
update: coa_core::modules::pbc::ConnectionUpdate,
|
||||
) -> std::result::Result<coa_core::modules::pbc::Setup, UiError> {
|
||||
let root = path_of(&state, &id)?;
|
||||
let _guard = BusyGuard::acquire(&state, &id)?;
|
||||
blocking(move || {
|
||||
let (dir, _) = install_meta(&root)?;
|
||||
coa_core::modules::pbc::save(&root, &dir, update)
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn all_settings(
|
||||
state: State<'_, AppState>,
|
||||
@@ -2446,6 +2480,7 @@ async fn add_companions(
|
||||
let meta = meta_dir(&root)?;
|
||||
let mut changes = BTreeMap::new();
|
||||
changes.insert("CoaBots.AutoLoginOnStartup".to_string(), Value::Bool(true));
|
||||
// Preserve the configured startup limit (CoaBots.AutoLogin.MaxCount); only set it when there is none.
|
||||
let existing_cfg = config::load(&target.world_root, Scope::Bots)?;
|
||||
let existing_max = existing_cfg
|
||||
.settings
|
||||
@@ -2453,13 +2488,12 @@ async fn add_companions(
|
||||
.find(|s| s.meta.key == "CoaBots.AutoLogin.MaxCount")
|
||||
.and_then(|s| s.value.as_u64())
|
||||
.unwrap_or(0) as u32;
|
||||
let already = coa_core::population::query_for_realm(&root, mode)
|
||||
.map(|p| p.bots_total)
|
||||
.unwrap_or(0);
|
||||
changes.insert(
|
||||
"CoaBots.AutoLogin.MaxCount".to_string(),
|
||||
Value::from(existing_max.max(already + count).min(5000)),
|
||||
);
|
||||
if existing_max == 0 {
|
||||
changes.insert(
|
||||
"CoaBots.AutoLogin.MaxCount".to_string(),
|
||||
Value::from(count.min(5000)),
|
||||
);
|
||||
}
|
||||
config::save(&target.world_root, &meta, Scope::Bots, &changes)?;
|
||||
|
||||
let mut baseline = None;
|
||||
@@ -2467,14 +2501,33 @@ async fn add_companions(
|
||||
if let Ok(admin_db) = coa_core::db::Db::from_repack(&root, coa_core::db::Account::Admin) {
|
||||
let _ = coa_core::companions::ensure_templates_for_schema(&admin_db, target.chars_db);
|
||||
}
|
||||
baseline = coa_core::population::query_for_realm(&root, mode)
|
||||
.ok()
|
||||
.map(|p| p.bots_total);
|
||||
let population = coa_core::population::query_for_realm(&root, mode).ok();
|
||||
baseline = population.as_ref().map(|p| p.bots_total);
|
||||
let mut ra = Ra::connect_target(&root, Some(mode))?;
|
||||
if let Some(lvl) = level {
|
||||
Some(ra.spawn_custom(count, lvl, class_id, spec_id, archetype.as_deref())?)
|
||||
} else {
|
||||
Some(ra.spawn_bots(count)?)
|
||||
// Bots that already exist and are offline come back first; only the rest are created.
|
||||
let offline = population
|
||||
.as_ref()
|
||||
.map(|p| p.bots_total.saturating_sub(p.bots_online))
|
||||
.unwrap_or(0);
|
||||
let mut reused = 0;
|
||||
if offline > 0 {
|
||||
match ra.login_offline_bots(count.min(offline)) {
|
||||
Ok(queued) => reused = queued,
|
||||
// An older bots module cannot log in a given number: create them all, as before.
|
||||
Err(Error::CompanionCommandUnsupported) => {}
|
||||
Err(error) => return Err(error),
|
||||
}
|
||||
}
|
||||
// The progress bar counts from the baseline, so reused bots count as done.
|
||||
baseline = baseline.map(|total| total.saturating_sub(reused));
|
||||
if count > reused {
|
||||
Some(ra.spawn_bots(count - reused)?)
|
||||
} else {
|
||||
Some(format!("BotMgr: queued {reused} offline bot(s) for login."))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let _ = coa_core::companions::migrate_legacy_pending_job(&meta, &id);
|
||||
@@ -3845,6 +3898,9 @@ pub fn run() {
|
||||
module_set_enabled,
|
||||
module_update,
|
||||
module_settings,
|
||||
pbc_connection,
|
||||
pbc_list_models,
|
||||
pbc_save_connection,
|
||||
module_save_settings,
|
||||
all_settings,
|
||||
all_settings_save,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "CSM Modules Preview",
|
||||
"version": "0.9.15",
|
||||
"version": "0.9.18",
|
||||
"identifier": "com.corfirean.csm-modules-preview",
|
||||
"build": {
|
||||
"beforeBuildCommand": "npm run build",
|
||||
|
||||
Reference in new issue
Block a user