add some CK3dEntity code
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
#include "../CK2/MgrImpls/CKObjectManager.hpp"
|
||||
#include "../CK2/ObjImpls/CKObject.hpp"
|
||||
#include <type_traits>
|
||||
#include <algorithm>
|
||||
|
||||
namespace LibCmo::XContainer {
|
||||
|
||||
@ -143,6 +144,13 @@ namespace LibCmo::XContainer {
|
||||
}
|
||||
namespace NSXObjectPointerArray {
|
||||
|
||||
void AddIfNotHere(XObjectPointerArray& objarray, CK2::ObjImpls::CKObject* const obj) {
|
||||
auto finder = std::find(objarray.begin(), objarray.end(), obj);
|
||||
if (finder == objarray.end()) {
|
||||
objarray.emplace_back(obj);
|
||||
}
|
||||
}
|
||||
|
||||
void PreDeletedCheck(XObjectPointerArray& objarray, CK2::CKContext* ctx) {
|
||||
if (ctx == nullptr) return;
|
||||
std::erase_if(objarray, [ctx](CK2::ObjImpls::CKObject* const& item) -> bool {
|
||||
|
@ -180,6 +180,13 @@ namespace LibCmo::XContainer {
|
||||
|
||||
namespace NSXObjectPointerArray {
|
||||
|
||||
/**
|
||||
* @brief Add object pointer if it is not list.
|
||||
* @param objarray
|
||||
* @param obj
|
||||
*/
|
||||
void AddIfNotHere(XObjectPointerArray& objarray, CK2::ObjImpls::CKObject* const obj);
|
||||
|
||||
/**
|
||||
* @brief Check Object pointer validation and remove invalid pointers before deletion.
|
||||
* @param objarray
|
||||
|
Reference in New Issue
Block a user