diff --git a/crates/coa-core/src/analyzer.rs b/crates/coa-core/src/analyzer.rs index e0044e5..b4500a5 100644 --- a/crates/coa-core/src/analyzer.rs +++ b/crates/coa-core/src/analyzer.rs @@ -936,7 +936,16 @@ pub fn parse_and_validate_github_url(url_str: &str) -> Result<(String, String, O /// - Symlinks and junctions rejected /// - Strictly read-only analysis: NO execution of CMake, build scripts, or SQL migrations pub fn analyze_github_repository(url_str: &str, cache_base_dir: Option<&Path>) -> Result { - let (owner, repo, ref_opt) = parse_and_validate_github_url(url_str)?; + let (mut owner, mut repo, mut ref_opt) = parse_and_validate_github_url(url_str)?; + + // Redirect upstream unadapted playerbots to verified CoA fork + if (owner.eq_ignore_ascii_case("Zyth45") || owner.eq_ignore_ascii_case("azerothcore")) && repo.eq_ignore_ascii_case("mod-playerbots") { + owner = "Corfirean".into(); + repo = "mod-playerbots".into(); + if ref_opt.is_none() { + ref_opt = Some("coa".into()); + } + } let base_cache = match cache_base_dir { Some(p) => p.to_path_buf(), diff --git a/crates/coa-core/src/build_engine.rs b/crates/coa-core/src/build_engine.rs index a494615..f5c7601 100644 --- a/crates/coa-core/src/build_engine.rs +++ b/crates/coa-core/src/build_engine.rs @@ -261,27 +261,33 @@ pub fn resolve_module_identity(source_dir: &Path) -> (String, String, Option "NPC Buffer".to_string(), - "ah-bot" => "Auction House Bot".to_string(), - "guildhouse" => "Guildhouse".to_string(), - "congrats-on-level" => "Congrats on Level".to_string(), - "npc-enchanter" => "NPC Enchanter".to_string(), - "reward-played-time" => "Reward Played Time".to_string(), - "transmog" => "Transmog".to_string(), - "solocraft" => "Solocraft".to_string(), - "autobalance" => "AutoBalance".to_string(), - "individual-progression" => "Individual Progression".to_string(), - "ale" => "AzerothCore Lua Engine (ALE)".to_string(), - "coa-playerbots" | "playerbots" | "companions" => "CoA Companions".to_string(), - "squid-playerbots" | "squid" => "SQUID's Playerbots".to_string(), - "coa-content-scaling" | "content-scaling" | "scaling" => "Content Scaling".to_string(), - "custom-races" => "Custom Races".to_string(), - "timeistime" => "TimeIsTime".to_string(), + let (module_id, display_name) = match raw_id.as_str() { + "coa-content-scaling" | "content-scaling" | "scaling" => { + ("content-scaling".to_string(), "Content Scaling".to_string()) + } + "coa-playerbots" | "companions" => { + ("companions".to_string(), "CoA Companions".to_string()) + } + "squid-playerbots" | "playerbots" | "squid" => { + ("playerbots".to_string(), "SQUID's Playerbots".to_string()) + } + "npc-buffer" => ("npc-buffer".to_string(), "NPC Buffer".to_string()), + "ah-bot" => ("ah-bot".to_string(), "Auction House Bot".to_string()), + "guildhouse" => ("guildhouse".to_string(), "Guildhouse".to_string()), + "congrats-on-level" => ("congrats-on-level".to_string(), "Congrats on Level".to_string()), + "npc-enchanter" => ("npc-enchanter".to_string(), "NPC Enchanter".to_string()), + "reward-played-time" => ("reward-played-time".to_string(), "Reward Played Time".to_string()), + "transmog" => ("transmog".to_string(), "Transmog".to_string()), + "solocraft" => ("solocraft".to_string(), "Solocraft".to_string()), + "autobalance" => ("autobalance".to_string(), "AutoBalance".to_string()), + "individual-progression" => ("individual-progression".to_string(), "Individual Progression".to_string()), + "ale" => ("ale".to_string(), "AzerothCore Lua Engine (ALE)".to_string()), + "custom-races" => ("custom-races".to_string(), "Custom Races".to_string()), + "timeistime" | "time-is-time" => ("time-is-time".to_string(), "TimeIsTime".to_string()), other => { - other.split('-') + let pretty = other.split('-') .map(|word| { let mut chars = word.chars(); match chars.next() { @@ -290,7 +296,8 @@ pub fn resolve_module_identity(source_dir: &Path) -> (String, String, Option>() - .join(" ") + .join(" "); + (other.to_string(), pretty) } }; @@ -489,6 +496,23 @@ pub fn build_module_from_source( }; let dest = staging_src.join(&dest_file_name); fs::copy(cpp, &dest)?; + + // Resilient compatibility patching for older / cached mod-coa-playerbots + if dest_file_name == "BotMgr.cpp" { + if let Ok(content) = fs::read_to_string(&dest) { + if content.contains("_GetPurchasedTabsSize") || content.contains("_CreateNewBankTab") { + let patched = content + .replace("guild->_GetPurchasedTabsSize()", "guild->GetPurchasedTabsSize()") + .replace("if (guild->_GetPurchasedTabsSize() == 0)\n guild->_CreateNewBankTab();", "guild->EnsureFirstBankTab();") + .replace("if (guild->_GetPurchasedTabsSize() == 0)\r\n guild->_CreateNewBankTab();", "guild->EnsureFirstBankTab();") + .replace("guild->_CreateNewBankTab()", "guild->EnsureFirstBankTab()") + .replace("Guild::BankTab const* tab = guild->GetBankTab(tabId);\n if (!tab)\n continue;\n for (uint8 slotId = 0; slotId < GUILD_BANK_MAX_SLOTS; ++slotId)\n if (Item const* item = tab->GetItem(slotId))", "for (uint8 slotId = 0; slotId < GUILD_BANK_MAX_SLOTS; ++slotId)\n if (Item const* item = guild->GetBankItem(tabId, slotId))") + .replace("Guild::BankTab const* tab = guild->GetBankTab(tabId);\r\n if (!tab)\r\n continue;\r\n for (uint8 slotId = 0; slotId < GUILD_BANK_MAX_SLOTS; ++slotId)\r\n if (Item const* item = tab->GetItem(slotId))", "for (uint8 slotId = 0; slotId < GUILD_BANK_MAX_SLOTS; ++slotId)\r\n if (Item const* item = guild->GetBankItem(tabId, slotId))"); + let _ = fs::write(&dest, patched); + } + } + } + staged_cpp_paths.push(dest.to_string_lossy().replace('\\', "/")); } diff --git a/crates/coa-core/src/modules.rs b/crates/coa-core/src/modules.rs index a0d24dd..7a68d00 100644 --- a/crates/coa-core/src/modules.rs +++ b/crates/coa-core/src/modules.rs @@ -249,19 +249,39 @@ fn list_in(cat: &[Entry], root: &Path) -> Vec { .or_else(|| r.plugins.get(&e.id.replace('-', "_"))) .or_else(|| r.plugins.get(&format!("mod-{}", e.id))) .or_else(|| r.plugins.get(&format!("mod-coa-{}", e.id))) + .or_else(|| r.plugins.get(&format!("coa-{}", e.id))) + .or_else(|| r.plugins.get(&format!("coa_{}", e.id))) + .or_else(|| match e.id.as_str() { + "content-scaling" => r.plugins.get("coa-content-scaling").or_else(|| r.plugins.get("mod-coa-content-scaling")), + "companions" => r.plugins.get("coa-playerbots").or_else(|| r.plugins.get("mod-coa-playerbots")), + "playerbots" => r.plugins.get("squid-playerbots").or_else(|| r.plugins.get("mod-playerbots")), + _ => None, + }) }); - let dll_present = root.join("plugins").join(format!("{}.dll", e.id)).is_file() - || root.join("plugins").join(format!("{}.dll", e.id.replace('-', "_"))).is_file() - || root.join("plugins").join(format!("mod-{}.dll", e.id)).is_file() - || root.join("plugins").join(format!("mod-{}.dll", e.id.replace('-', "_"))).is_file() - || root.join("plugins").join(format!("mod-coa-{}.dll", e.id)).is_file() - || root.join("plugins").join(format!("mod_coa_{}.dll", e.id.replace('-', "_"))).is_file() - || root.join(".manager/plugins").join(format!("{}.dll", e.id)).is_file() - || root.join(".manager/plugins").join(format!("{}.dll", e.id.replace('-', "_"))).is_file() - || root.join(".manager/plugins").join(format!("mod-{}.dll", e.id)).is_file() - || root.join(".manager/plugins").join(format!("mod-{}.dll", e.id.replace('-', "_"))).is_file() - || root.join(".manager/plugins").join(format!("mod-coa-{}.dll", e.id)).is_file() - || root.join(".manager/plugins").join(format!("mod_coa_{}.dll", e.id.replace('-', "_"))).is_file(); + + let dll_candidates = [ + root.join("plugins").join(format!("{}.dll", e.id)), + root.join("plugins").join(format!("{}.dll", e.id.replace('-', "_"))), + root.join("plugins").join(format!("coa-{}.dll", e.id)), + root.join("plugins").join(format!("coa_{}.dll", e.id.replace('-', "_"))), + root.join("plugins").join(format!("mod-{}.dll", e.id)), + root.join("plugins").join(format!("mod-{}.dll", e.id.replace('-', "_"))), + root.join("plugins").join(format!("mod-coa-{}.dll", e.id)), + root.join("plugins").join(format!("mod_coa_{}.dll", e.id.replace('-', "_"))), + // Subdirectory checks (plugins/{id}/{id}.dll) + root.join("plugins").join(&e.id).join(format!("{}.dll", e.id)), + root.join("plugins").join(format!("coa-{}", e.id)).join(format!("coa-{}.dll", e.id)), + root.join("plugins").join(format!("mod-{}", e.id)).join(format!("mod-{}.dll", e.id)), + root.join("plugins").join(format!("mod-coa-{}", e.id)).join(format!("mod-coa-{}.dll", e.id)), + // Special alias subdirectories + root.join("plugins").join("coa-content-scaling").join("coa-content-scaling.dll"), + root.join("plugins").join("coa-playerbots").join("coa-playerbots.dll"), + // .manager/plugins checks + root.join(".manager/plugins").join(format!("{}.dll", e.id)), + root.join(".manager/plugins").join(format!("coa-{}.dll", e.id)), + root.join(".manager/plugins").join(format!("mod-coa-{}.dll", e.id)), + ]; + let dll_present = dll_candidates.iter().any(|p| p.is_file()); let is_dynamic = plugin_entry.is_some() || dll_present; // 2. Classify ComponentType and determine installation strictly @@ -279,18 +299,21 @@ fn list_in(cat: &[Entry], root: &Path) -> Vec { let se_plugin = plugin_reg.as_ref().and_then(|r| { r.plugins.get("content-scaling") .or_else(|| r.plugins.get("content_scaling")) + .or_else(|| r.plugins.get("coa-content-scaling")) .or_else(|| r.plugins.get("mod-coa-content-scaling")) }); let se_dll = root.join("plugins").join("content-scaling.dll").is_file() - || root.join("plugins").join("content_scaling.dll").is_file() + || root.join("plugins").join("content-scaling").join("content-scaling.dll").is_file() + || root.join("plugins").join("coa-content-scaling").join("coa-content-scaling.dll").is_file() + || root.join("plugins").join("coa-content-scaling.dll").is_file() || root.join("plugins").join("mod-coa-content-scaling.dll").is_file() - || root.join("plugins").join("mod_coa_content_scaling.dll").is_file() || root.join(".manager/plugins").join("content-scaling.dll").is_file() + || root.join(".manager/plugins").join("coa-content-scaling.dll").is_file() || root.join(".manager/plugins").join("mod-coa-content-scaling.dll").is_file(); se_plugin.is_some() || se_dll || (!is_modular_host && installed_commits.contains_key("scaling")) }; - let has_content = is_scaling_installed && (conf.is_file() || dist.is_file()); + let has_content = is_scaling_installed; (ComponentType::ContentPack, has_content, false) } else if e.id == "client-compat" { (ComponentType::LogicalFeature, true, false) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 2ee80e2..13df03a 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -2944,6 +2944,7 @@ async fn preview_register_test_realm( #[tauri::command] async fn preview_build_module( + app: AppHandle, state: State<'_, AppState>, realm_id: String, source_url_or_path: String, @@ -2958,22 +2959,32 @@ async fn preview_build_module( let realm_root = path_of(&state, &realm_id)?; let cache_dir = data_dir().join("github_cache"); + let app_clone = app.clone(); + let progress_cb: Box = + Box::new(move |event| { + let _ = app_clone.emit("preview_build_progress", &event); + }); + blocking(move || { let source_dir = if source_url_or_path.starts_with("http://") || source_url_or_path.starts_with("https://") { - let (owner, repo, _) = coa_core::analyzer::parse_and_validate_github_url(&source_url_or_path)?; - let repo_cache = cache_dir.join("github").join(&owner).join(&repo); - let _ = coa_core::analyzer::analyze_github_module_for_realm(&source_url_or_path, &realm_root, Some(&cache_dir))?; - - let mut found = None; - if let Ok(entries) = std::fs::read_dir(&repo_cache) { - for entry in entries.flatten() { - if entry.path().is_dir() && entry.path().join(".coa_tree_digest").is_file() { - found = Some(entry.path()); - break; + let report = coa_core::analyzer::analyze_github_module_for_realm(&source_url_or_path, &realm_root, Some(&cache_dir))?; + let p = PathBuf::from(&report.repository_path); + if p.is_dir() { + p + } else { + let (owner, repo, _) = coa_core::analyzer::parse_and_validate_github_url(&source_url_or_path)?; + let repo_cache = cache_dir.join("github").join(&owner).join(&repo); + let mut found = None; + if let Ok(entries) = std::fs::read_dir(&repo_cache) { + for entry in entries.flatten() { + if entry.path().is_dir() && entry.path().join(".coa_tree_digest").is_file() { + found = Some(entry.path()); + break; + } } } + found.ok_or_else(|| coa_core::Error::Invalid("Failed to locate cached repository sources after intake".into()))? } - found.ok_or_else(|| coa_core::Error::Invalid("Failed to locate cached repository sources after intake".into()))? } else { let p = PathBuf::from(&source_url_or_path); if p.exists() { @@ -3000,7 +3011,7 @@ async fn preview_build_module( } }; - coa_core::build_engine::build_module_from_source(&source_dir, &realm_root, None, None) + coa_core::build_engine::build_module_from_source(&source_dir, &realm_root, None, Some(progress_cb)) .map_err(Into::into) }) .await diff --git a/src/screens/ModulesPage.tsx b/src/screens/ModulesPage.tsx index 45fc053..4fd4459 100644 --- a/src/screens/ModulesPage.tsx +++ b/src/screens/ModulesPage.tsx @@ -265,7 +265,7 @@ const VERIFIED_CATALOG: VerifiedCatalogModule[] = [ { id: "playerbots", name: "SQUID's Playerbots", - repo: "https://github.com/Zyth45/mod-playerbots", + repo: "https://github.com/Corfirean/mod-playerbots", category: "official", description: { ru: "Альтернативная система ботов со случайными ботами и полным ИИ.", @@ -625,6 +625,12 @@ export function ModulesPage({ const [building, setBuilding] = useState(false); const [buildResult, setBuildResult] = useState(null); const [buildLogs, setBuildLogs] = useState([]); + const [buildProgress, setBuildProgress] = useState<{ + step: string; + progress_pct: number; + message: string; + elapsedSeconds: number; + } | null>(null); // Installation & SQL confirmation modal const [installing, setInstalling] = useState(false); @@ -840,7 +846,39 @@ export function ModulesPage({ setBuilding(true); setActiveTab("builds"); setBuildLogs(["[CSM Controlled Build Engine] Initializing build environment..."]); + setBuildProgress({ + step: "PREPARING", + progress_pct: 10, + message: locale === "ru" ? "Инициализация среды сборки MSVC и SDK..." : "Initializing MSVC and SDK build environment...", + elapsedSeconds: 0, + }); + + const startTime = Date.now(); + const timer = setInterval(() => { + const elapsed = (Date.now() - startTime) / 1000; + setBuildProgress((prev) => (prev ? { ...prev, elapsedSeconds: elapsed } : null)); + }, 100); + + let unlisten: (() => void) | null = null; try { + try { + unlisten = await listen<{ step: string; progress_pct: number; message: string; log_line?: string }>( + "preview_build_progress", + (event) => { + const p = event.payload; + setBuildProgress((prev) => ({ + step: p.step, + progress_pct: p.progress_pct, + message: p.message, + elapsedSeconds: prev ? prev.elapsedSeconds : (Date.now() - startTime) / 1000, + })); + if (p.log_line) { + setBuildLogs((logs) => [...logs, p.log_line!]); + } + } + ); + } catch {} + setBuildLogs((prev) => [ ...prev, `Target module: ${target}`, @@ -850,6 +888,12 @@ export function ModulesPage({ setBuildResult(res); setBuildLogs(res.log_output); if (res.success) { + setBuildProgress({ + step: "SUCCESS", + progress_pct: 100, + message: locale === "ru" ? "Сборка завершена успешно" : "Build completed successfully", + elapsedSeconds: (Date.now() - startTime) / 1000, + }); setNotification( locale === "ru" ? `Сборка успешно завершена! DLL '${res.display_name || res.module_id}' квалифицирована: ${res.dll_sha256?.substring(0, 16)}...` @@ -867,6 +911,8 @@ export function ModulesPage({ setAnalysisError(errText); setBuildLogs((prev) => [...prev, `[FATAL BUILD ERROR]: ${errText}`]); } finally { + clearInterval(timer); + unlisten?.(); setBuilding(false); } } @@ -939,7 +985,8 @@ export function ModulesPage({ } const isScalingInstalled = Boolean( - modules?.some((m) => m.id === "content-scaling" && m.installed) + modules?.some((m) => (m.id === "content-scaling" || m.id === "coa-content-scaling") && m.installed) || + installedPlugins?.some((p) => p.id === "content-scaling" || p.id === "coa-content-scaling") ); const installedModules = (modules?.filter((m) => m.installed) ?? []).filter((m) => { @@ -1336,6 +1383,37 @@ export function ModulesPage({ + {/* Sticky Active Build Banner when user is outside the builds tab */} + {building && buildProgress && activeTab !== "builds" && ( +
setActiveTab("builds")} + className="cursor-pointer rounded-lg border border-gold/40 bg-gold/10 p-3 flex items-center justify-between shadow transition-colors hover:bg-gold/15 animate-in fade-in" + > +
+ +
+
+ + {locale === "ru" ? "Идет сборка модуля" : "Building module"} + + [{buildProgress.step}] + — {buildProgress.message} +
+
+
+
+
+
+
+ {buildProgress.progress_pct}% + ({buildProgress.elapsedSeconds.toFixed(1)}s) +
+
+ )} + {/* TAB 0: INSTALLED MODULES */} {activeTab === "installed" && (
@@ -1851,10 +1929,20 @@ export function ModulesPage({
{filteredVerifiedCatalog.map((item) => { const matchedModule = modules?.find( - (m) => m.id === item.id || m.name.toLowerCase() === item.name.toLowerCase() + (m) => + m.id === item.id || + m.id === `coa-${item.id}` || + m.id === `mod-coa-${item.id}` || + m.name.toLowerCase() === item.name.toLowerCase() ); - const isInstalled = Boolean(matchedModule?.installed); - const isEnabled = Boolean(matchedModule?.enabled); + const matchedPlugin = installedPlugins?.find( + (p) => + p.id === item.id || + p.id === `coa-${item.id}` || + p.name.toLowerCase() === item.name.toLowerCase() + ); + const isInstalled = Boolean(matchedModule?.installed || matchedPlugin); + const isEnabled = Boolean(matchedModule?.enabled ?? matchedPlugin?.enabled ?? false); return ( @@ -2474,6 +2562,36 @@ export function ModulesPage({ {/* TAB 4: BUILDS & MSVC LOGS */} {activeTab === "builds" && (
+ {/* Active Build Progress Bar */} + {building && buildProgress && ( + +
+
+ + {buildProgress.step} + — {buildProgress.message} +
+
+ {buildProgress.progress_pct}% + ({buildProgress.elapsedSeconds.toFixed(1)}s) +
+
+ + {/* Animated Progress Track */} +
+
+
+ +
+ {locale === "ru" ? "Используется Cl.exe & Ninja (MSVC x64 /MD)" : "Using Cl.exe & Ninja (MSVC x64 /MD)"} + {locale === "ru" ? "Прогресс сборки и линковки DLL" : "DLL build and link progress"} +
+ + )} + {/* Build Result Card */} {buildResult && (