finish ckgroup again
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
#include "CKSceneObject.hpp"
|
||||
#include "../CKStateChunk.hpp"
|
||||
#include "CKBeObject.hpp"
|
||||
#include "CKGroup.hpp"
|
||||
|
||||
namespace LibCmo::CK2::ObjImpls {
|
||||
|
||||
@ -19,7 +20,10 @@ namespace LibCmo::CK2::ObjImpls {
|
||||
}
|
||||
|
||||
bool CKBeObject::IsInGroup(CKGroup* group) {
|
||||
return false;
|
||||
if (group == nullptr) return false;
|
||||
CKDWORD idx = group->CKBeObject_GetGroupIndex();
|
||||
if (idx >= m_Groups.size()) return false;
|
||||
return m_Groups[idx];
|
||||
}
|
||||
|
||||
void CKBeObject::CKGroup_SetGroups(CKDWORD pos, bool val) {
|
||||
|
@ -25,10 +25,35 @@ namespace LibCmo::CK2::ObjImpls {
|
||||
bool suc = CKBeObject::Load(chunk, file);
|
||||
if (!suc) return false;
|
||||
|
||||
// cleat self
|
||||
this->Clear();
|
||||
|
||||
// get grouped objects
|
||||
if (chunk->SeekIdentifier(CK_STATESAVEFLAGS_GROUP::CK_STATESAVE_GROUPALL)) {
|
||||
XContainer::XObjectPointerArray ptrs;
|
||||
chunk->ReadXObjectPointerArray(ptrs);
|
||||
|
||||
// filter pointer and check them type
|
||||
for (auto& ptr : ptrs) {
|
||||
// skip bad one
|
||||
if (ptr == nullptr || ptr == this
|
||||
|| !CKIsChildClassOf(ptr->GetClassID(), CK_CLASSID::CKCID_BEOBJECT)) {
|
||||
continue;
|
||||
}
|
||||
CKBeObject* beobj = static_cast<CKBeObject*>(ptr);
|
||||
if (beobj->IsInGroup(this)) continue;
|
||||
|
||||
// add good one
|
||||
beobj->CKGroup_SetGroups(m_GroupIndex, true);
|
||||
m_ObjectArray.emplace_back(beobj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CKDWORD CKGroup::GetGroupIndex() {
|
||||
CKDWORD CKGroup::CKBeObject_GetGroupIndex() {
|
||||
return m_GroupIndex;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ namespace LibCmo::CK2::ObjImpls {
|
||||
virtual bool Load(CKStateChunk* chunk, CKFileVisitor* file) override;
|
||||
//virtual void PostLoad() override;
|
||||
|
||||
CKDWORD GetGroupIndex();
|
||||
CKDWORD CKBeObject_GetGroupIndex();
|
||||
|
||||
// ===== Insert =====
|
||||
CKERROR AddObject(CKBeObject *o);
|
||||
|
Reference in New Issue
Block a user