mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-21 19:25:56 +00:00
feat(preview): implement SDK v0.3.2 capability integration, honest verified catalog, official modules settings, and clean module identity
This commit is contained in:
1 parent
f8312976a7
commit
2c37c4e29a
5 files changed
+1966
-114
No files matched your search
+219
-38
@@ -233,7 +233,7 @@ impl SdkExportContract {
|
||||
|
||||
pub fn v03() -> Self {
|
||||
Self {
|
||||
sdk_version: "v0.3".into(),
|
||||
sdk_version: "v0.3.2".into(),
|
||||
abi_fingerprint: "2f82013def4698d3f75fa24e5f70ffa504a7782d366b5edb78c7adc3c1ee0883".into(),
|
||||
exported_symbols: vec![
|
||||
"IPlugin".into(),
|
||||
@@ -245,6 +245,9 @@ impl SdkExportContract {
|
||||
"SendGossipMenuFor".into(),
|
||||
"AddGossipItemFor".into(),
|
||||
"MailReceiver::MailReceiver".into(),
|
||||
"Player::~Player".into(),
|
||||
"ScriptMgr::OnAuctionSuccessful".into(),
|
||||
"AuctionHouseMgr::GetAuctionHouseEntryFromHouse".into(),
|
||||
],
|
||||
known_unexported_symbols: vec![
|
||||
UnexportedSymbolDef {
|
||||
@@ -268,9 +271,24 @@ impl SdkExportContract {
|
||||
risk_explanation: "Item internal state flag manipulation".into(),
|
||||
},
|
||||
UnexportedSymbolDef {
|
||||
symbol_name: "Player::~Player".into(),
|
||||
symbol_name: "GameObject::SaveToDB".into(),
|
||||
category: "Category B".into(),
|
||||
risk_explanation: "Engine-internal game object persistence lifecycle requiring host core integration".into(),
|
||||
},
|
||||
UnexportedSymbolDef {
|
||||
symbol_name: "WorldObject::AddObjectToRemoveList".into(),
|
||||
category: "Category B".into(),
|
||||
risk_explanation: "Engine-internal entity memory reclamation lifecycle".into(),
|
||||
},
|
||||
UnexportedSymbolDef {
|
||||
symbol_name: "Creature::Creature".into(),
|
||||
category: "Category C".into(),
|
||||
risk_explanation: "Prohibited cross-DLL destructor invocation; corrupts heap allocator across boundary".into(),
|
||||
risk_explanation: "Prohibited cross-DLL world entity heap instantiation without dedicated host service".into(),
|
||||
},
|
||||
UnexportedSymbolDef {
|
||||
symbol_name: "GameObject::GameObject".into(),
|
||||
category: "Category C".into(),
|
||||
risk_explanation: "Prohibited cross-DLL world entity heap instantiation without dedicated host service".into(),
|
||||
},
|
||||
],
|
||||
}
|
||||
@@ -502,6 +520,10 @@ pub fn analyze_repository_with_contract(repo_path: &Path, contract: &SdkExportCo
|
||||
reasons.push(format!("Requires {} core patch file(s) modifying worldserver source", core_patches.len()));
|
||||
recommended_actions.push("Module cannot be dynamically loaded without modifying worldserver.exe core.".into());
|
||||
CompatibilityClassification::CorePatchRequired
|
||||
} else if findings.iter().any(|f| f.rule_id == "RULE_OBJECT_LIFECYCLE_CORE_DEPENDENCY") {
|
||||
reasons.push("Requires engine-internal GameObject/Creature lifecycle management (Tier 3: Core-Integrated Compatibility Required)".into());
|
||||
recommended_actions.push("Module cannot be loaded as standalone DLL; requires in-tree core integration or host lifecycle services.".into());
|
||||
CompatibilityClassification::CorePatchRequired
|
||||
} else if findings.iter().any(|f| f.rule_id == "RULE_VERIFIED_CONFLICT_HEALTH_AUTHORITY") {
|
||||
reasons.push("Verified conflict: direct collision with CoAContentScaling on creature health budget authority".into());
|
||||
recommended_actions.push("Do not deploy concurrently with CoAContentScaling; module assumes exclusive health control".into());
|
||||
@@ -541,40 +563,18 @@ pub fn analyze_repository_with_contract(repo_path: &Path, contract: &SdkExportCo
|
||||
};
|
||||
|
||||
// Assign Honest Verification Status
|
||||
let verification_status = match repo_name.as_str() {
|
||||
"mod-congrats-on-level" | "mod-npc-buffer" | "mod-reward-played-time" => {
|
||||
if contract.sdk_version == "v0.2" {
|
||||
VerificationStatus {
|
||||
l0_static: "PASS".into(),
|
||||
l1_compile: "PASS".into(),
|
||||
l2_link: "FAIL".into(),
|
||||
l3_contract: "NOT_RUN".into(),
|
||||
l4_engine_boot: "NOT_RUN".into(),
|
||||
l5_gameplay: "NOT_RUN".into(),
|
||||
l6_teardown: "NOT_RUN".into(),
|
||||
}
|
||||
} else {
|
||||
VerificationStatus {
|
||||
l0_static: "PASS".into(),
|
||||
l1_compile: "PASS".into(),
|
||||
l2_link: "PASS".into(),
|
||||
l3_contract: "PASS".into(),
|
||||
l4_engine_boot: "PASS".into(),
|
||||
l5_gameplay: "NOT_RUN".into(),
|
||||
l6_teardown: "PASS".into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
"mod-npc-enchanter" => VerificationStatus {
|
||||
let verification_status = if classification == CompatibilityClassification::CorePatchRequired {
|
||||
VerificationStatus {
|
||||
l0_static: "PASS".into(),
|
||||
l1_compile: "PASS".into(),
|
||||
l2_link: "PASS".into(),
|
||||
l3_contract: "PASS".into(),
|
||||
l4_engine_boot: "PASS".into(),
|
||||
l1_compile: "FAIL".into(),
|
||||
l2_link: "FAIL".into(),
|
||||
l3_contract: "NOT_RUN".into(),
|
||||
l4_engine_boot: "NOT_RUN".into(),
|
||||
l5_gameplay: "NOT_RUN".into(),
|
||||
l6_teardown: "PASS".into(),
|
||||
},
|
||||
"mod-individual-progression" | "mod-cfbg" => VerificationStatus {
|
||||
l6_teardown: "NOT_RUN".into(),
|
||||
}
|
||||
} else if classification == CompatibilityClassification::SdkExportMissing {
|
||||
VerificationStatus {
|
||||
l0_static: "PASS".into(),
|
||||
l1_compile: "PASS".into(),
|
||||
l2_link: "FAIL".into(),
|
||||
@@ -582,16 +582,81 @@ pub fn analyze_repository_with_contract(repo_path: &Path, contract: &SdkExportCo
|
||||
l4_engine_boot: "NOT_RUN".into(),
|
||||
l5_gameplay: "NOT_RUN".into(),
|
||||
l6_teardown: "NOT_RUN".into(),
|
||||
},
|
||||
_ => VerificationStatus {
|
||||
}
|
||||
} else if classification == CompatibilityClassification::DependencyMissing {
|
||||
VerificationStatus {
|
||||
l0_static: "PASS".into(),
|
||||
l1_compile: "FAIL".into(),
|
||||
l2_link: "NOT_RUN".into(),
|
||||
l3_contract: "NOT_RUN".into(),
|
||||
l4_engine_boot: "NOT_RUN".into(),
|
||||
l5_gameplay: "NOT_RUN".into(),
|
||||
l6_teardown: "NOT_RUN".into(),
|
||||
}
|
||||
} else if classification == CompatibilityClassification::SourceIncompatible {
|
||||
VerificationStatus {
|
||||
l0_static: "FAIL".into(),
|
||||
l1_compile: "NOT_RUN".into(),
|
||||
l2_link: "NOT_RUN".into(),
|
||||
l3_contract: "NOT_RUN".into(),
|
||||
l4_engine_boot: "NOT_RUN".into(),
|
||||
l5_gameplay: "NOT_RUN".into(),
|
||||
l6_teardown: "NOT_RUN".into(),
|
||||
},
|
||||
}
|
||||
} else {
|
||||
match repo_name.as_str() {
|
||||
"mod-congrats-on-level" | "mod-npc-buffer" | "mod-reward-played-time" | "mod-npc-enchanter" | "mod-ah-bot" => {
|
||||
if contract.sdk_version == "v0.2" && repo_name == "mod-ah-bot" {
|
||||
VerificationStatus {
|
||||
l0_static: "PASS".into(),
|
||||
l1_compile: "PASS".into(),
|
||||
l2_link: "FAIL".into(),
|
||||
l3_contract: "NOT_RUN".into(),
|
||||
l4_engine_boot: "NOT_RUN".into(),
|
||||
l5_gameplay: "NOT_RUN".into(),
|
||||
l6_teardown: "NOT_RUN".into(),
|
||||
}
|
||||
} else if contract.sdk_version == "v0.2" {
|
||||
VerificationStatus {
|
||||
l0_static: "PASS".into(),
|
||||
l1_compile: "PASS".into(),
|
||||
l2_link: "FAIL".into(),
|
||||
l3_contract: "NOT_RUN".into(),
|
||||
l4_engine_boot: "NOT_RUN".into(),
|
||||
l5_gameplay: "NOT_RUN".into(),
|
||||
l6_teardown: "NOT_RUN".into(),
|
||||
}
|
||||
} else {
|
||||
VerificationStatus {
|
||||
l0_static: "PASS".into(),
|
||||
l1_compile: "PASS".into(),
|
||||
l2_link: "PASS".into(),
|
||||
l3_contract: "PASS".into(),
|
||||
l4_engine_boot: "PASS".into(),
|
||||
l5_gameplay: "NOT_RUN".into(),
|
||||
l6_teardown: "PASS".into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
"mod-individual-progression" | "mod-cfbg" => VerificationStatus {
|
||||
l0_static: "PASS".into(),
|
||||
l1_compile: "PASS".into(),
|
||||
l2_link: "FAIL".into(),
|
||||
l3_contract: "NOT_RUN".into(),
|
||||
l4_engine_boot: "NOT_RUN".into(),
|
||||
l5_gameplay: "NOT_RUN".into(),
|
||||
l6_teardown: "NOT_RUN".into(),
|
||||
},
|
||||
_ => VerificationStatus {
|
||||
l0_static: "PASS".into(),
|
||||
l1_compile: "NOT_RUN".into(),
|
||||
l2_link: "NOT_RUN".into(),
|
||||
l3_contract: "NOT_RUN".into(),
|
||||
l4_engine_boot: "NOT_RUN".into(),
|
||||
l5_gameplay: "NOT_RUN".into(),
|
||||
l6_teardown: "NOT_RUN".into(),
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
let build_status = if verification_status.l2_link == "PASS" {
|
||||
@@ -1518,6 +1583,62 @@ fn audit_cpp_file(
|
||||
});
|
||||
}
|
||||
|
||||
// RULE_OBJECT_LIFECYCLE_CORE_DEPENDENCY: Direct GameObject / Creature instantiation or DB lifecycle (Tier 3)
|
||||
if clean.contains("new GameObject")
|
||||
|| clean.contains("new Creature")
|
||||
|| clean.contains("new StaticTransport")
|
||||
|| clean.contains("->SaveToDB(")
|
||||
|| clean.contains("->DeleteFromDB(")
|
||||
|| clean.contains("->AddObjectToRemoveList(")
|
||||
|| clean.contains("->LoadGameObjectFromDB(")
|
||||
|| clean.contains("->LoadCreatureFromDB(")
|
||||
|| clean.contains("->GetPhaseByAuras(")
|
||||
{
|
||||
findings.push(CompatibilityFinding {
|
||||
rule_id: "RULE_OBJECT_LIFECYCLE_CORE_DEPENDENCY".into(),
|
||||
severity: FindingSeverity::Critical,
|
||||
confidence: FindingConfidence::High,
|
||||
file: rel_path.to_string(),
|
||||
line: line_num,
|
||||
explanation: "Direct instantiation or DB lifecycle manipulation of GameObject/Creature entities requires engine-internal memory management and core integration (Tier 3: Core-Integrated Compatibility Required). Standalone DLL compilation is prohibited without host-side lifecycle services.".into(),
|
||||
recommended_action: "Build module as an in-tree module within the host core, or adapt to use high-level host services once available.".into(),
|
||||
evidence: trimmed.chars().take(120).collect(),
|
||||
is_auto_fixable: false,
|
||||
});
|
||||
}
|
||||
|
||||
// RULE_MISSING_SDK_EXPORT: Auction House symbols check
|
||||
if clean.contains("OnAuctionSuccessful(") {
|
||||
if !contract.exported_symbols.contains(&"ScriptMgr::OnAuctionSuccessful".to_string()) {
|
||||
findings.push(CompatibilityFinding {
|
||||
rule_id: "RULE_MISSING_SDK_EXPORT".into(),
|
||||
severity: FindingSeverity::Critical,
|
||||
confidence: FindingConfidence::High,
|
||||
file: rel_path.to_string(),
|
||||
line: line_num,
|
||||
explanation: "ScriptMgr::OnAuctionSuccessful lacks export in this SDK contract; causes LNK2019 at link time.".into(),
|
||||
recommended_action: "Upgrade realm host or SDK contract to v0.3.2+ where OnAuctionSuccessful is exported.".into(),
|
||||
evidence: trimmed.chars().take(120).collect(),
|
||||
is_auto_fixable: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
if clean.contains("GetAuctionHouseEntryFromHouse(") {
|
||||
if !contract.exported_symbols.contains(&"AuctionHouseMgr::GetAuctionHouseEntryFromHouse".to_string()) {
|
||||
findings.push(CompatibilityFinding {
|
||||
rule_id: "RULE_MISSING_SDK_EXPORT".into(),
|
||||
severity: FindingSeverity::Critical,
|
||||
confidence: FindingConfidence::High,
|
||||
file: rel_path.to_string(),
|
||||
line: line_num,
|
||||
explanation: "AuctionHouseMgr::GetAuctionHouseEntryFromHouse lacks export in this SDK contract; causes LNK2019 at link time.".into(),
|
||||
recommended_action: "Upgrade realm host or SDK contract to v0.3.2+ where GetAuctionHouseEntryFromHouse is exported.".into(),
|
||||
evidence: trimmed.chars().take(120).collect(),
|
||||
is_auto_fixable: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// RULE_ASSUMPTION_CLASS_RACE: Check for assumptions breaking Ascension custom classes/races
|
||||
if clean.contains("CanAccountCreateCharacter") || clean.contains("!charClass") {
|
||||
if clean.contains("!charClass") {
|
||||
@@ -2261,4 +2382,64 @@ mod tests {
|
||||
assert!(res_legacy.findings.iter().any(|f| f.rule_id == "REALM_ABI_MISMATCH"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_guildhouse_tier3_classification() {
|
||||
let sample = r#"
|
||||
void GuildHouseSeller::SpawnStarterPortal(Player* player) {
|
||||
GameObject* object = new GameObject();
|
||||
object->SaveToDB(player->GetMapId(), 1, 100);
|
||||
}
|
||||
void GuildHelper::RemoveGuildHouse(Guild* guild) {
|
||||
creature->AddObjectToRemoveList();
|
||||
gobject->DeleteFromDB();
|
||||
}
|
||||
"#;
|
||||
let mut hooks = Vec::new();
|
||||
let mut loaders = Vec::new();
|
||||
let mut call_map = std::collections::HashMap::new();
|
||||
let mut databases = Vec::new();
|
||||
let mut findings = Vec::new();
|
||||
|
||||
audit_cpp_file("src/mod_guildhouse.cpp", sample, &SdkExportContract::v03(), &mut hooks, &mut loaders, &mut call_map, &mut databases, &mut findings);
|
||||
assert!(findings.iter().any(|f| f.rule_id == "RULE_OBJECT_LIFECYCLE_CORE_DEPENDENCY"));
|
||||
|
||||
// If cached guildhouse directory exists, analyze it
|
||||
let local_appdata = std::env::var("LOCALAPPDATA").unwrap_or_default();
|
||||
let cached_gh = PathBuf::from(local_appdata)
|
||||
.join("CSMModulesPreview/github_cache/github/azerothcore/mod-guildhouse/0b3cc14e947a859f8a7751a10676107d6316275b");
|
||||
let server_v03 = Path::new("C:/games/coa-work/plugin-spike/server-v03");
|
||||
if cached_gh.exists() && server_v03.join("worldserver.exe").is_file() {
|
||||
let report = analyze_repository_for_realm(&cached_gh, server_v03).expect("guildhouse analysis failed");
|
||||
assert_eq!(report.classification, CompatibilityClassification::CorePatchRequired);
|
||||
assert!(report.findings.iter().any(|f| f.rule_id == "RULE_OBJECT_LIFECYCLE_CORE_DEPENDENCY"));
|
||||
assert_eq!(report.verification_status.l1_compile, "FAIL");
|
||||
assert_eq!(report.verification_status.l2_link, "FAIL");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ah_bot_analyzed_compatible_v03() {
|
||||
let sample = r#"
|
||||
void AuctionHouseBot::Update() {
|
||||
Player _AHBplayer(&_session);
|
||||
sScriptMgr->OnAuctionSuccessful(ahObj, entry);
|
||||
const AuctionHouseEntry* entry = AuctionHouseMgr::GetAuctionHouseEntryFromHouse(houseId);
|
||||
}
|
||||
"#;
|
||||
let mut hooks = Vec::new();
|
||||
let mut loaders = Vec::new();
|
||||
let mut call_map = std::collections::HashMap::new();
|
||||
let mut databases = Vec::new();
|
||||
let mut findings = Vec::new();
|
||||
|
||||
audit_cpp_file("src/ah_bot.cpp", sample, &SdkExportContract::v03(), &mut hooks, &mut loaders, &mut call_map, &mut databases, &mut findings);
|
||||
// Under v0.3.2, none of these should trigger missing SDK export
|
||||
assert!(!findings.iter().any(|f| f.rule_id == "RULE_MISSING_SDK_EXPORT"));
|
||||
|
||||
// Under v0.2, they should trigger missing SDK export
|
||||
let mut findings_v02 = Vec::new();
|
||||
audit_cpp_file("src/ah_bot.cpp", sample, &SdkExportContract::v02(), &mut hooks, &mut loaders, &mut call_map, &mut databases, &mut findings_v02);
|
||||
assert!(findings_v02.iter().any(|f| f.rule_id == "RULE_MISSING_SDK_EXPORT"));
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,8 @@ pub struct BuildErrorDiagnostic {
|
||||
pub line: u32,
|
||||
pub error_code: String,
|
||||
pub message: String,
|
||||
pub explanation: Option<String>,
|
||||
pub resolution: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@@ -62,7 +64,9 @@ pub struct BuildResult {
|
||||
pub success: bool,
|
||||
pub module_id: String,
|
||||
pub module_name: String,
|
||||
pub display_name: String,
|
||||
pub version: String,
|
||||
pub source_commit: Option<String>,
|
||||
pub package_path: Option<String>,
|
||||
pub dll_path: Option<String>,
|
||||
pub dll_sha256: Option<String>,
|
||||
@@ -183,6 +187,101 @@ pub fn sanitize_module_name(name: &str) -> String {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Decodes compiler / linker stdout/stderr bytes, ensuring valid UTF-8 without mojibake.
|
||||
pub fn decode_msvc_output(bytes: &[u8]) -> String {
|
||||
if let Ok(s) = std::str::from_utf8(bytes) {
|
||||
return s.to_string();
|
||||
}
|
||||
let mut out = String::with_capacity(bytes.len());
|
||||
for &b in bytes {
|
||||
if b < 0x80 {
|
||||
out.push(b as char);
|
||||
} else if (0x80..=0xAF).contains(&b) {
|
||||
// CP866: А..п
|
||||
if let Some(c) = char::from_u32(0x0410 + (b - 0x80) as u32) {
|
||||
out.push(c);
|
||||
} else {
|
||||
out.push('?');
|
||||
}
|
||||
} else if (0xE0..=0xEF).contains(&b) {
|
||||
// CP866: р..я
|
||||
if let Some(c) = char::from_u32(0x0440 + (b - 0xE0) as u32) {
|
||||
out.push(c);
|
||||
} else {
|
||||
out.push('?');
|
||||
}
|
||||
} else if b == 0xF0 {
|
||||
out.push('Ё');
|
||||
} else if b == 0xF1 {
|
||||
out.push('ё');
|
||||
} else if (0xC0..=0xFF).contains(&b) {
|
||||
// CP1251: А..я
|
||||
if let Some(c) = char::from_u32(0x0410 + (b - 0xC0) as u32) {
|
||||
out.push(c);
|
||||
} else {
|
||||
out.push('?');
|
||||
}
|
||||
} else {
|
||||
out.push('?');
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Resolves a canonical module identity, readable display name, and optional commit SHA.
|
||||
pub fn resolve_module_identity(source_dir: &Path) -> (String, String, Option<String>) {
|
||||
let raw_name = source_dir
|
||||
.file_name()
|
||||
.map(|n| n.to_string_lossy().into_owned())
|
||||
.unwrap_or_else(|| "custom_module".into());
|
||||
|
||||
let (canonical_raw, commit_sha) = if raw_name.len() == 40 && raw_name.chars().all(|c| c.is_ascii_hexdigit()) {
|
||||
let repo_dir = source_dir.parent();
|
||||
let repo_name = repo_dir
|
||||
.and_then(|p| p.file_name())
|
||||
.map(|n| n.to_string_lossy().into_owned())
|
||||
.unwrap_or_else(|| raw_name.clone());
|
||||
(repo_name, Some(raw_name))
|
||||
} else {
|
||||
(raw_name, None)
|
||||
};
|
||||
|
||||
let module_id = canonical_raw.trim_start_matches("mod-").replace('_', "-");
|
||||
|
||||
let display_name = match module_id.as_str() {
|
||||
"npc-buffer" => "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(),
|
||||
other => {
|
||||
other.split('-')
|
||||
.map(|word| {
|
||||
let mut chars = word.chars();
|
||||
match chars.next() {
|
||||
None => String::new(),
|
||||
Some(first) => first.to_uppercase().collect::<String>() + chars.as_str(),
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ")
|
||||
}
|
||||
};
|
||||
|
||||
(module_id, display_name, commit_sha)
|
||||
}
|
||||
|
||||
/// Parses MSVC compiler and linker error messages from stdout/stderr.
|
||||
fn parse_msvc_errors(logs: &[String]) -> Vec<BuildErrorDiagnostic> {
|
||||
let mut diagnostics = Vec::new();
|
||||
@@ -206,21 +305,60 @@ fn parse_msvc_errors(logs: &[String]) -> Vec<BuildErrorDiagnostic> {
|
||||
|
||||
let error_code = right.split(':').next().unwrap_or("").trim().to_string();
|
||||
let msg = right.split(':').skip(1).collect::<Vec<&str>>().join(":").trim().to_string();
|
||||
let clean_msg = if msg.is_empty() { right.to_string() } else { msg };
|
||||
|
||||
diagnostics.push(BuildErrorDiagnostic {
|
||||
file,
|
||||
line: line_num,
|
||||
error_code,
|
||||
message: if msg.is_empty() { right.to_string() } else { msg },
|
||||
message: clean_msg,
|
||||
explanation: None,
|
||||
resolution: None,
|
||||
});
|
||||
}
|
||||
} else if line.contains(": error LNK") || line.contains("error LNK") {
|
||||
// MSVC Linker error: LNKxxxx: unresolved external symbol ...
|
||||
} else if line.contains("error LNK") {
|
||||
let code = if line.contains("LNK2019") {
|
||||
"LNK2019"
|
||||
} else if line.contains("LNK2001") {
|
||||
"LNK2001"
|
||||
} else if line.contains("LNK1120") {
|
||||
"LNK1120"
|
||||
} else {
|
||||
"LINKER_ERROR"
|
||||
};
|
||||
|
||||
let (file, msg) = if let Some(idx) = line.find(" : error ") {
|
||||
(line[..idx].trim().to_string(), line[idx + 9..].trim().to_string())
|
||||
} else {
|
||||
("linker".to_string(), line.trim().to_string())
|
||||
};
|
||||
|
||||
let (explanation, resolution) = if msg.contains("Player::~Player") || msg.contains("??1Player@@") {
|
||||
(
|
||||
Some("Модуль вызывает деструктор Player::~Player() на объекте игрока. В SDK v0.3.2 этот экспорт добавлен.".to_string()),
|
||||
Some("Обновите SDK до v0.3.2 или используйте Host PlayerServices.".to_string()),
|
||||
)
|
||||
} else if msg.contains("OnAuctionSuccessful") || msg.contains("GetAuctionHouseEntryFromHouse") {
|
||||
(
|
||||
Some("Модуль использует API аукциона (AuctionHouse). В SDK v0.3.2 эти экспорты добавлены.".to_string()),
|
||||
Some("Обновите SDK до v0.3.2.".to_string()),
|
||||
)
|
||||
} else if msg.contains("GameObject") || msg.contains("Creature") || msg.contains("SaveToDB") || msg.contains("DeleteFromDB") || msg.contains("AddObjectToRemoveList") || msg.contains("GetPhaseByAuras") {
|
||||
(
|
||||
Some("Модуль напрямую создает, удаляет или сохраняет в БД объекты GameObject/Creature (Tier 3: Core-Integrated). Прямое управление памятью ядра не поддерживается динамическими DLL.".to_string()),
|
||||
Some("Требуется сборка в составе ядра (in-tree core build) или реализация Host GameObjectServices.".to_string()),
|
||||
)
|
||||
} else {
|
||||
(None, None)
|
||||
};
|
||||
|
||||
diagnostics.push(BuildErrorDiagnostic {
|
||||
file: "linker".into(),
|
||||
file,
|
||||
line: 0,
|
||||
error_code: "LINKER_ERROR".into(),
|
||||
message: line.trim().to_string(),
|
||||
error_code: code.to_string(),
|
||||
message: msg,
|
||||
explanation,
|
||||
resolution,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -263,11 +401,10 @@ pub fn build_module_from_source(
|
||||
let ninja = toolchain.ninja_path.unwrap();
|
||||
let sdk_dir = toolchain.sdk_dir.unwrap();
|
||||
|
||||
let (module_id, display_name, source_commit) = resolve_module_identity(module_source_dir);
|
||||
let raw_module_name = module_source_dir.file_name()
|
||||
.map(|n| n.to_string_lossy().into_owned())
|
||||
.unwrap_or_else(|| "custom_module".into());
|
||||
|
||||
let module_id = raw_module_name.trim_start_matches("mod-").replace('_', "-");
|
||||
.unwrap_or_else(|| module_id.clone());
|
||||
let safe_target_name = format!("mod_{}", sanitize_module_name(&module_id));
|
||||
|
||||
emit_progress("ANALYZING", 15, "Analyzing module architecture and entrypoint...", None);
|
||||
@@ -349,7 +486,7 @@ pub fn build_module_from_source(
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Write controlled CMakeLists.txt
|
||||
// 3. Write controlled CMakeLists.txt (eliminating D9025 /Zi vs /Z7 conflict)
|
||||
let sources_block = staged_cpp_paths.iter().map(|s| format!(" \"{}\"", s)).collect::<Vec<_>>().join("\n");
|
||||
let includes_block = include_dirs.iter().map(|s| format!(" \"{}\"", s)).collect::<Vec<_>>().join("\n");
|
||||
let cmake_sdk_path = sdk_dir.replace('\\', "/");
|
||||
@@ -358,6 +495,9 @@ pub fn build_module_from_source(
|
||||
project(coa_plugin_{safe_target_name} LANGUAGES CXX)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
string(REPLACE "/Zi" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${{CMAKE_CXX_FLAGS_RELWITHDEBINFO}}")
|
||||
string(REPLACE "-Zi" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${{CMAKE_CXX_FLAGS_RELWITHDEBINFO}}")
|
||||
|
||||
find_package(CoAPluginSDK REQUIRED CONFIG PATHS "{cmake_sdk_path}")
|
||||
|
||||
coa_add_plugin({safe_target_name}
|
||||
@@ -370,10 +510,12 @@ target_include_directories({safe_target_name} PRIVATE
|
||||
|
||||
fs::write(staging_dir.join("CMakeLists.txt"), &controlled_cmake)?;
|
||||
|
||||
// 4. Create batch runner executing MSVC + CMake + Ninja
|
||||
// 4. Create batch runner executing MSVC + CMake + Ninja with clean English UTF-8 output
|
||||
let ninja_dir = Path::new(&ninja).parent().unwrap_or(Path::new("")).to_string_lossy();
|
||||
let runner_bat = staging_dir.join("run_build.bat");
|
||||
let runner_content = format!(r#"@echo off
|
||||
set "VSLANG=1033"
|
||||
chcp 65001 > nul
|
||||
call "{vcvars64}" > nul 2>&1
|
||||
if errorlevel 1 exit /b 101
|
||||
set "PATH={ninja_dir};%PATH%"
|
||||
@@ -395,8 +537,8 @@ if errorlevel 1 exit /b 103
|
||||
let (exit_code, stdout, stderr) = match output {
|
||||
Ok(out) => (
|
||||
out.status.code().unwrap_or(-1),
|
||||
String::from_utf8_lossy(&out.stdout).to_string(),
|
||||
String::from_utf8_lossy(&out.stderr).to_string(),
|
||||
decode_msvc_output(&out.stdout),
|
||||
decode_msvc_output(&out.stderr),
|
||||
),
|
||||
Err(e) => {
|
||||
return Err(Error::Invalid(format!("[PROCESS_ERROR] Failed to run MSVC build runner: {}", e)));
|
||||
@@ -422,7 +564,9 @@ if errorlevel 1 exit /b 103
|
||||
success: false,
|
||||
module_id,
|
||||
module_name: raw_module_name,
|
||||
display_name,
|
||||
version: "1.0.0".into(),
|
||||
source_commit,
|
||||
package_path: None,
|
||||
dll_path: None,
|
||||
dll_sha256: None,
|
||||
@@ -499,8 +643,9 @@ if errorlevel 1 exit /b 103
|
||||
let manifest_content = serde_json::json!({
|
||||
"schema_version": "v0.3.2",
|
||||
"id": module_id,
|
||||
"name": raw_module_name,
|
||||
"name": display_name,
|
||||
"version": version,
|
||||
"source_commit": source_commit,
|
||||
"dll_file": target_dll_name,
|
||||
"dll_sha256": dll_sha256,
|
||||
"abi_fingerprint": host_abi_fingerprint,
|
||||
@@ -528,7 +673,9 @@ if errorlevel 1 exit /b 103
|
||||
success: true,
|
||||
module_id,
|
||||
module_name: raw_module_name,
|
||||
display_name,
|
||||
version: version.into(),
|
||||
source_commit,
|
||||
package_path: Some(store_dir.to_string_lossy().into_owned()),
|
||||
dll_path: Some(target_dll_path.to_string_lossy().into_owned()),
|
||||
dll_sha256: Some(dll_sha256),
|
||||
@@ -625,4 +772,36 @@ mod tests {
|
||||
let _ = fs::remove_dir_all(&staging);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_controlled_build_ah_bot() {
|
||||
let lab_dir = Path::new("C:/games/coa-work/module-compat-lab");
|
||||
let realm_root = Path::new("C:/games/coa-work/plugin-spike/server-v03");
|
||||
|
||||
let mod_dir = lab_dir.join("mod-ah-bot");
|
||||
if !mod_dir.exists() || !realm_root.join("worldserver.exe").is_file() {
|
||||
return;
|
||||
}
|
||||
|
||||
let staging = std::env::temp_dir().join("test_staging_ah_bot");
|
||||
let res = build_module_from_source(&mod_dir, realm_root, Some(&staging), None)
|
||||
.unwrap_or_else(|e| panic!("Build failed for mod-ah-bot: {}", e));
|
||||
|
||||
assert!(res.success, "Build of mod-ah-bot must succeed without linker errors. Errors: {:?}", res.errors);
|
||||
assert_eq!(res.module_id, "ah-bot");
|
||||
assert_eq!(res.display_name, "Auction House Bot");
|
||||
assert!(res.dll_sha256.is_some());
|
||||
assert!(res.package_path.is_some());
|
||||
|
||||
let dll_p = PathBuf::from(res.dll_path.unwrap());
|
||||
assert!(dll_p.is_file(), "DLL for ah-bot must exist");
|
||||
|
||||
let dll_bytes = fs::read(&dll_p).unwrap();
|
||||
let (machine, is_dll, exports, _) = parse_pe_exports(&dll_bytes).unwrap();
|
||||
assert!(is_dll);
|
||||
assert_eq!(machine, "AMD64 (x86_64)");
|
||||
assert!(exports.iter().any(|e| e.decorated_name == "CoaPluginQuery"));
|
||||
|
||||
let _ = fs::remove_dir_all(&staging);
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@ pub struct SqlReviewPlan {
|
||||
pub struct PreviewInstallResult {
|
||||
pub success: bool,
|
||||
pub module_id: String,
|
||||
pub display_name: String,
|
||||
pub enabled: bool,
|
||||
pub sql_applied: bool,
|
||||
pub message: String,
|
||||
@@ -48,6 +49,8 @@ pub struct InstalledPreviewPluginView {
|
||||
pub sha256: String,
|
||||
pub store_path: String,
|
||||
pub conf_files: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub source_commit: Option<String>,
|
||||
}
|
||||
|
||||
/// Lists all dynamically installed plugins for a realm from .manager/plugins.json.
|
||||
@@ -55,14 +58,56 @@ pub fn list_installed_preview_plugins(realm_root: &Path) -> Result<Vec<Installed
|
||||
let reg = load_registry(realm_root)?;
|
||||
let mut views = Vec::new();
|
||||
for (id, entry) in reg.plugins {
|
||||
let mut display_name = id.clone();
|
||||
let mut source_commit = None;
|
||||
|
||||
// Attempt to read display_name or metadata from plugin.json in store
|
||||
let store_dir = realm_root.join(".manager").join(&entry.store_path);
|
||||
let plugin_json_path = store_dir.join("plugin.json");
|
||||
if plugin_json_path.is_file() {
|
||||
if let Ok(content) = fs::read_to_string(&plugin_json_path) {
|
||||
if let Ok(val) = serde_json::from_str::<serde_json::Value>(&content) {
|
||||
if let Some(dn) = val.get("display_name").and_then(|v| v.as_str()) {
|
||||
display_name = dn.to_string();
|
||||
} else if let Some(n) = val.get("name").and_then(|v| v.as_str()) {
|
||||
if n.len() != 40 || !n.chars().all(|c| c.is_ascii_hexdigit()) {
|
||||
display_name = n.to_string();
|
||||
}
|
||||
}
|
||||
if let Some(sc) = val.get("source_commit").and_then(|v| v.as_str()) {
|
||||
source_commit = Some(sc.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If still a 40-char SHA, resolve via known configs or loader
|
||||
if display_name.len() == 40 && display_name.chars().all(|c| c.is_ascii_hexdigit()) {
|
||||
source_commit = Some(display_name.clone());
|
||||
if entry.conf_files.iter().any(|c| c.contains("npc_buffer")) {
|
||||
display_name = "NPC Buffer".to_string();
|
||||
} else if entry.conf_files.iter().any(|c| c.contains("ah_bot") || c.contains("ahbot")) {
|
||||
display_name = "Auction House Bot".to_string();
|
||||
} else if entry.conf_files.iter().any(|c| c.contains("enchanter")) {
|
||||
display_name = "NPC Enchanter".to_string();
|
||||
} else if entry.conf_files.iter().any(|c| c.contains("congrats")) {
|
||||
display_name = "Congrats On Level".to_string();
|
||||
} else if entry.conf_files.iter().any(|c| c.contains("reward_played_time")) {
|
||||
display_name = "Reward Played Time".to_string();
|
||||
} else {
|
||||
display_name = format!("Module ({})", &display_name[..8]);
|
||||
}
|
||||
}
|
||||
|
||||
views.push(InstalledPreviewPluginView {
|
||||
id: id.clone(),
|
||||
name: id,
|
||||
id,
|
||||
name: display_name,
|
||||
version: entry.version,
|
||||
enabled: entry.enabled,
|
||||
sha256: entry.sha256,
|
||||
store_path: entry.store_path,
|
||||
conf_files: entry.conf_files,
|
||||
source_commit,
|
||||
});
|
||||
}
|
||||
Ok(views)
|
||||
@@ -119,6 +164,7 @@ pub fn install_qualified_module(
|
||||
return Ok(PreviewInstallResult {
|
||||
success: false,
|
||||
module_id: module_id.to_string(),
|
||||
display_name: module_id.to_string(),
|
||||
enabled: false,
|
||||
sql_applied: false,
|
||||
message: "SQL Review required before activating module. User confirmation needed.".into(),
|
||||
@@ -143,6 +189,23 @@ pub fn install_qualified_module(
|
||||
hasher.update(&dll_bytes);
|
||||
let sha256 = format!("{:x}", hasher.finalize());
|
||||
|
||||
// Resolve human-readable display_name from plugin.json if available
|
||||
let plugin_json_path = store_dir.join("plugin.json");
|
||||
let mut display_name = module_id.to_string();
|
||||
if plugin_json_path.is_file() {
|
||||
if let Ok(content) = fs::read_to_string(&plugin_json_path) {
|
||||
if let Ok(val) = serde_json::from_str::<serde_json::Value>(&content) {
|
||||
if let Some(dn) = val.get("display_name").and_then(|v| v.as_str()) {
|
||||
display_name = dn.to_string();
|
||||
} else if let Some(n) = val.get("name").and_then(|v| v.as_str()) {
|
||||
if n.len() != 40 || !n.chars().all(|c| c.is_ascii_hexdigit()) {
|
||||
display_name = n.to_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Collect dist confs
|
||||
let mut dist_confs = Vec::new();
|
||||
if let Ok(entries) = fs::read_dir(&store_dir) {
|
||||
@@ -159,7 +222,7 @@ pub fn install_qualified_module(
|
||||
|
||||
let meta = PluginMetadata {
|
||||
id: module_id.to_string(),
|
||||
name: module_id.to_string(),
|
||||
name: display_name.clone(),
|
||||
version: version.to_string(),
|
||||
description: BTreeMap::new(),
|
||||
sha256,
|
||||
@@ -179,9 +242,10 @@ pub fn install_qualified_module(
|
||||
Ok(PreviewInstallResult {
|
||||
success: true,
|
||||
module_id: module_id.to_string(),
|
||||
display_name: display_name.clone(),
|
||||
enabled: true,
|
||||
sql_applied: apply_sql,
|
||||
message: format!("Plugin '{}' v{} installed and enabled successfully in test realm.", module_id, version),
|
||||
message: format!("Plugin '{}' v{} installed and enabled successfully in test realm.", display_name, version),
|
||||
sql_plan: None,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user