diff --git a/src/cad_mcp_frame/mcp_ConfigParser.cpp b/src/cad_mcp_frame/mcp_ConfigParser.cpp index dcc111a..d95b9a3 100644 --- a/src/cad_mcp_frame/mcp_ConfigParser.cpp +++ b/src/cad_mcp_frame/mcp_ConfigParser.cpp @@ -158,13 +158,35 @@ void mcp_ConfigParser::LoadDllTool(const nlohmann::json &toolConfig, const std:: // 基座自身版本取「编译期常量」,它稳定可靠; // 不能依赖运行时的 acrxGetApiVersion()——该函数由 rxapi.lib 中的有状态实现提供, // 其返回值会随调用次数变化(首次为正确值,之后被进程内全局污染),无法用于比对。 - int arx_version = (ARX << 16) | SUB_ARX; - int dll_version = getVerFn(); - mcpLoadLog("arx_version=" + std::to_string(arx_version) + " dll_version=" + std::to_string(dll_version)); + // 返回值编码为 (major << 16) | minor:高 16 位=大版本,低 16 位=小版本。 + const int arx_version = (ARX << 16) | SUB_ARX; + const int arx_major = ARX; + const int arx_minor = SUB_ARX; - if (arx_version != dll_version) + const int dll_version = getVerFn(); + const int dll_major = (dll_version >> 16) & 0xFFFF; + const int dll_minor = dll_version & 0xFFFF; + + mcpLoadLog("arx_version=" + std::to_string(arx_version) + + " dll_version=" + std::to_string(dll_version) + + " (arx " + std::to_string(arx_major) + "." + std::to_string(arx_minor) + + " / dll " + std::to_string(dll_major) + "." + std::to_string(dll_minor) + ")"); + + // 兼容性判定: + // - 同一大版本内通常二进制兼容(如 R24.0/R24.1/R24.2 可共用同一 ARX),故默认只比大版本; + // - 唯一例外是 R24.3:它换了 MSVC toolset,与 R24.0~R24.2 不兼容,需单独分组比较。 + bool compatible = false; + if (dll_major == arx_major) { - // 平台大版本不匹配,强行加载必定闪崩,果断踢掉整个模块! + if (arx_major == 24) + compatible = ((arx_minor >= 3) == (dll_minor >= 3)); // 24.3+ 与 24.0~24.2 互不兼容 + else + compatible = true; + } + + if (!compatible) + { + // 平台不兼容,强行加载必定闪崩,果断踢掉整个模块! FreeLibrary(hMod); g_loadedDllModules.erase(key); AfxMessageBox(ver_errMsg);