1
0

fix: fix XContainer

This commit is contained in:
2026-01-24 17:55:57 +08:00
parent ff2600c8fb
commit 34de35dd31

View File

@@ -40,11 +40,11 @@ namespace LibCmo::XContainer {
ba[n] = false; ba[n] = false;
} }
template<bool _Cond> template<bool BCondition>
static bool GeneralGetBitPosition(const XBitArray& ba, CKDWORD n, CKDWORD& got) { static bool GeneralGetBitPosition(const XBitArray& ba, CKDWORD n, CKDWORD& got) {
CKDWORD counter = 0; CKDWORD counter = 0;
for (size_t i = 0; i < ba.size(); ++i) { for (size_t i = 0; i < ba.size(); ++i) {
if (ba[i] == _Cond) { if (ba[i] == BCondition) {
if (counter == n) { if (counter == n) {
got = static_cast<CKDWORD>(i); got = static_cast<CKDWORD>(i);
return true; return true;
@@ -81,18 +81,14 @@ namespace LibCmo::XContainer {
} }
template<class _Ty> template<class T, bool BIsPre>
static constexpr bool GeneralXArrayCheck_TypeCheck() { requires (std::is_same_v<T, CK2::CK_ID> || std::is_same_v<T, CK2::ObjImpls::CKObject*>)
return std::is_same_v<_Ty, CK2::CK_ID> || std::is_same_v<_Ty, CK2::ObjImpls::CKObject*>; static bool GeneralXArrayCheck_ItemCheck(const T& item, CK2::CKContext* ctx) {
}
template<class _Ty, bool _IsPre>
static bool GeneralXArrayCheck_ItemCheck(const _Ty& item, CK2::CKContext* ctx) {
static_assert(GeneralXArrayCheck_TypeCheck<_Ty>());
if (ctx == nullptr) return false; if (ctx == nullptr) return false;
if constexpr (_IsPre) { if constexpr (BIsPre) {
CK2::ObjImpls::CKObject* obj = nullptr; CK2::ObjImpls::CKObject* obj = nullptr;
if constexpr (std::is_same_v<_Ty, CK2::CK_ID>) { if constexpr (std::is_same_v<T, CK2::CK_ID>) {
obj = ctx->GetObject(item); obj = ctx->GetObject(item);
if (obj == nullptr) return false; if (obj == nullptr) return false;
} else { } else {
@@ -101,7 +97,7 @@ namespace LibCmo::XContainer {
if (obj->IsToBeDeleted()) return false; if (obj->IsToBeDeleted()) return false;
} else { } else {
CK2::MgrImpls::CKObjectManager* objmgr = ctx->GetObjectManager(); CK2::MgrImpls::CKObjectManager* objmgr = ctx->GetObjectManager();
if constexpr (std::is_same_v<_Ty, CK2::CK_ID>) { if constexpr (std::is_same_v<T, CK2::CK_ID>) {
if (!objmgr->IsObjectSafe(item)) return false; if (!objmgr->IsObjectSafe(item)) return false;
} else { } else {
if (!objmgr->IsObjectPointerSafe(item)) return false; if (!objmgr->IsObjectPointerSafe(item)) return false;