refactor: fix BMap build issue.
- fix BMap build issue with new YYCC. - rename most "General" into "Generic". - remove useless code.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include "BMExports.hpp"
|
||||
#include <YYCCommonplace.hpp>
|
||||
#include <yycc.hpp>
|
||||
#include <set>
|
||||
#include <type_traits>
|
||||
#include <memory>
|
||||
@@ -28,8 +28,9 @@ bool CheckBMMeshTrans(BMap::BMMeshTransition* possible_trans) {
|
||||
return (g_IsInited && possible_trans != nullptr && g_AllBMMeshTrans.contains(possible_trans));
|
||||
}
|
||||
|
||||
template<class _Ty, std::enable_if_t<std::is_pointer_v<_Ty>, int> = 0>
|
||||
_Ty CheckGeneralObject(BMap::BMFile* possible_bmfile, LibCmo::CK2::CK_ID possible_id, LibCmo::CK2::CK_CLASSID expected_cid) {
|
||||
template<class T>
|
||||
requires std::is_pointer_v<T>
|
||||
T CheckGenericObject(BMap::BMFile* possible_bmfile, LibCmo::CK2::CK_ID possible_id, LibCmo::CK2::CK_CLASSID expected_cid) {
|
||||
// check bm file self.
|
||||
if (!CheckBMFile(possible_bmfile)) return nullptr;
|
||||
// check id
|
||||
@@ -37,18 +38,18 @@ _Ty CheckGeneralObject(BMap::BMFile* possible_bmfile, LibCmo::CK2::CK_ID possibl
|
||||
// check id validation and class id
|
||||
if (obj == nullptr || !LibCmo::CK2::CKIsChildClassOf(obj->GetClassID(), expected_cid)) return nullptr;
|
||||
|
||||
return static_cast<_Ty>(obj);
|
||||
return static_cast<T>(obj);
|
||||
}
|
||||
|
||||
#define CheckCKObject(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CKObject*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_OBJECT)
|
||||
#define CheckCKGroup(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CKGroup*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_GROUP)
|
||||
#define CheckCK3dEntity(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CK3dEntity*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_3DENTITY)
|
||||
#define CheckCK3dObject(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CK3dObject*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_3DOBJECT)
|
||||
#define CheckCKMesh(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CKMesh*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_MESH)
|
||||
#define CheckCKMaterial(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CKMaterial*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_MATERIAL)
|
||||
#define CheckCKTexture(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CKTexture*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_TEXTURE)
|
||||
#define CheckCKLight(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CKLight*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_LIGHT)
|
||||
#define CheckCKTargetLight(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CKTargetLight*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_TARGETLIGHT)
|
||||
#define CheckCKObject(bmfile, objid) CheckGenericObject<LibCmo::CK2::ObjImpls::CKObject*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_OBJECT)
|
||||
#define CheckCKGroup(bmfile, objid) CheckGenericObject<LibCmo::CK2::ObjImpls::CKGroup*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_GROUP)
|
||||
#define CheckCK3dEntity(bmfile, objid) CheckGenericObject<LibCmo::CK2::ObjImpls::CK3dEntity*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_3DENTITY)
|
||||
#define CheckCK3dObject(bmfile, objid) CheckGenericObject<LibCmo::CK2::ObjImpls::CK3dObject*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_3DOBJECT)
|
||||
#define CheckCKMesh(bmfile, objid) CheckGenericObject<LibCmo::CK2::ObjImpls::CKMesh*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_MESH)
|
||||
#define CheckCKMaterial(bmfile, objid) CheckGenericObject<LibCmo::CK2::ObjImpls::CKMaterial*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_MATERIAL)
|
||||
#define CheckCKTexture(bmfile, objid) CheckGenericObject<LibCmo::CK2::ObjImpls::CKTexture*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_TEXTURE)
|
||||
#define CheckCKLight(bmfile, objid) CheckGenericObject<LibCmo::CK2::ObjImpls::CKLight*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_LIGHT)
|
||||
#define CheckCKTargetLight(bmfile, objid) CheckGenericObject<LibCmo::CK2::ObjImpls::CKTargetLight*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_TARGETLIGHT)
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <VTAll.hpp>
|
||||
#include <yycc.hpp>
|
||||
#include <yycc/macro/class_copy_move.hpp>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include <cinttypes>
|
||||
@@ -14,7 +16,7 @@ namespace BMap {
|
||||
public:
|
||||
BMFile(LibCmo::CKSTRING temp_folder, LibCmo::CKSTRING texture_folder, NakedOutputCallback raw_callback, LibCmo::CKDWORD encoding_count, LibCmo::CKSTRING* encodings, bool is_reader);
|
||||
~BMFile();
|
||||
YYCC_DEL_CLS_COPY_MOVE(BMFile);
|
||||
YYCC_DELETE_COPY_MOVE(BMFile)
|
||||
|
||||
// ===== Safe Check Function =====
|
||||
|
||||
@@ -160,7 +162,7 @@ namespace BMap {
|
||||
public:
|
||||
BMMeshTransition();
|
||||
~BMMeshTransition();
|
||||
YYCC_DEL_CLS_COPY_MOVE(BMMeshTransition);
|
||||
YYCC_DELETE_COPY_MOVE(BMMeshTransition)
|
||||
|
||||
bool PrepareVertexCount(LibCmo::CKDWORD count);
|
||||
LibCmo::VxMath::VxVector3* PrepareVertex();
|
||||
|
||||
@@ -169,30 +169,30 @@ namespace LibCmo::CK2 {
|
||||
}
|
||||
|
||||
void CKContext::ExecuteManagersOnPreClearAll() {
|
||||
ExecuteManagersGeneral([](MgrImpls::CKBaseManager* mgr) -> void {
|
||||
ExecuteGenericManagers([](MgrImpls::CKBaseManager* mgr) -> void {
|
||||
mgr->PreClearAll();
|
||||
});
|
||||
}
|
||||
|
||||
void CKContext::ExecuteManagersOnPostClearAll() {
|
||||
ExecuteManagersGeneral([](MgrImpls::CKBaseManager* mgr) -> void {
|
||||
ExecuteGenericManagers([](MgrImpls::CKBaseManager* mgr) -> void {
|
||||
mgr->PostClearAll();
|
||||
});
|
||||
}
|
||||
|
||||
void CKContext::ExecuteManagersOnSequenceToBeDeleted(const CK_ID* objids, CKDWORD count) {
|
||||
ExecuteManagersGeneral([objids, count](MgrImpls::CKBaseManager* mgr) -> void {
|
||||
ExecuteGenericManagers([objids, count](MgrImpls::CKBaseManager* mgr) -> void {
|
||||
mgr->SequenceToBeDeleted(objids, count);
|
||||
});
|
||||
}
|
||||
|
||||
void CKContext::ExecuteManagersOnSequenceDeleted(const CK_ID* objids, CKDWORD count) {
|
||||
ExecuteManagersGeneral([objids, count](MgrImpls::CKBaseManager* mgr) -> void {
|
||||
ExecuteGenericManagers([objids, count](MgrImpls::CKBaseManager* mgr) -> void {
|
||||
mgr->SequenceDeleted(objids, count);
|
||||
});
|
||||
}
|
||||
|
||||
void CKContext::ExecuteManagersGeneral(std::function<void(MgrImpls::CKBaseManager*)> fct) {
|
||||
void CKContext::ExecuteGenericManagers(std::function<void(MgrImpls::CKBaseManager*)> fct) {
|
||||
for (auto& mgrptr : m_ManagerList) {
|
||||
fct(mgrptr);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace LibCmo::CK2 {
|
||||
void ExecuteManagersOnSequenceDeleted(const CK_ID* objids, CKDWORD count);
|
||||
|
||||
protected:
|
||||
void ExecuteManagersGeneral(std::function<void(MgrImpls::CKBaseManager*)> fct);
|
||||
void ExecuteGenericManagers(std::function<void(MgrImpls::CKBaseManager*)> fct);
|
||||
XContainer::XArray<MgrImpls::CKBaseManager*> m_ManagerList;
|
||||
|
||||
MgrImpls::CKObjectManager* m_ObjectManager;
|
||||
|
||||
@@ -274,11 +274,13 @@ namespace LibCmo::CK2 {
|
||||
public:
|
||||
bool SeekIdentifierDword(CKDWORD identifier);
|
||||
bool SeekIdentifierDwordAndReturnSize(CKDWORD identifier, CKDWORD* out_size);
|
||||
template<typename TEnum, std::enable_if_t<std::is_enum_v<TEnum>, int> = 0>
|
||||
template<typename TEnum>
|
||||
requires std::is_enum_v<TEnum>
|
||||
inline bool SeekIdentifier(TEnum enum_v) {
|
||||
return SeekIdentifierDword(static_cast<CKDWORD>(enum_v));
|
||||
}
|
||||
template<typename TEnum, std::enable_if_t<std::is_enum_v<TEnum>, int> = 0>
|
||||
template<typename TEnum>
|
||||
requires std::is_enum_v<TEnum>
|
||||
inline bool SeekIdentifierAndReturnSize(TEnum enum_v, CKDWORD* out_size) {
|
||||
return SeekIdentifierDwordAndReturnSize(static_cast<CKDWORD>(enum_v), out_size);
|
||||
}
|
||||
@@ -564,7 +566,8 @@ namespace LibCmo::CK2 {
|
||||
|
||||
public:
|
||||
bool WriteIdentifierDword(CKDWORD identifier);
|
||||
template<typename TEnum, std::enable_if_t<std::is_enum_v<TEnum>, int> = 0>
|
||||
template<typename TEnum>
|
||||
requires std::is_enum_v<TEnum>
|
||||
inline bool WriteIdentifier(TEnum enum_v) {
|
||||
return WriteIdentifierDword(static_cast<CKDWORD>(enum_v));
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace LibCmo::XContainer {
|
||||
}
|
||||
|
||||
template<bool BCondition>
|
||||
static bool GeneralGetBitPosition(const XBitArray& ba, CKDWORD n, CKDWORD& got) {
|
||||
static bool GenericGetBitPosition(const XBitArray& ba, CKDWORD n, CKDWORD& got) {
|
||||
CKDWORD counter = 0;
|
||||
for (size_t i = 0; i < ba.size(); ++i) {
|
||||
if (ba[i] == BCondition) {
|
||||
@@ -58,11 +58,11 @@ namespace LibCmo::XContainer {
|
||||
}
|
||||
|
||||
bool GetSetBitPosition(const XBitArray& ba, CKDWORD n, CKDWORD& got) {
|
||||
return GeneralGetBitPosition<true>(ba, n, got);
|
||||
return GenericGetBitPosition<true>(ba, n, got);
|
||||
}
|
||||
|
||||
bool GetUnsetBitPosition(const XBitArray& ba, CKDWORD n, CKDWORD& got) {
|
||||
return GeneralGetBitPosition<false>(ba, n, got);
|
||||
return GenericGetBitPosition<false>(ba, n, got);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -83,7 +83,7 @@ namespace LibCmo::XContainer {
|
||||
|
||||
template<class T, bool BIsPre>
|
||||
requires (std::is_same_v<T, CK2::CK_ID> || std::is_same_v<T, CK2::ObjImpls::CKObject*>)
|
||||
static bool GeneralXArrayCheck_ItemCheck(const T& item, CK2::CKContext* ctx) {
|
||||
static bool GenericXArrayCheck_ItemCheck(const T& item, CK2::CKContext* ctx) {
|
||||
if (ctx == nullptr) return false;
|
||||
|
||||
if constexpr (BIsPre) {
|
||||
@@ -111,14 +111,14 @@ namespace LibCmo::XContainer {
|
||||
void PreDeletedCheck(XObjectArray& objarray, CK2::CKContext* ctx) {
|
||||
if (ctx == nullptr) return;
|
||||
std::erase_if(objarray, [ctx](const CK2::CK_ID& item) -> bool {
|
||||
return GeneralXArrayCheck_ItemCheck<CK2::CK_ID, true>(item, ctx);
|
||||
return GenericXArrayCheck_ItemCheck<CK2::CK_ID, true>(item, ctx);
|
||||
});
|
||||
}
|
||||
|
||||
void PostDeletedCheck(XObjectArray& objarray, CK2::CKContext* ctx) {
|
||||
if (ctx == nullptr) return;
|
||||
std::erase_if(objarray, [ctx](const CK2::CK_ID& item) -> bool {
|
||||
return GeneralXArrayCheck_ItemCheck<CK2::CK_ID, false>(item, ctx);
|
||||
return GenericXArrayCheck_ItemCheck<CK2::CK_ID, false>(item, ctx);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -126,14 +126,14 @@ namespace LibCmo::XContainer {
|
||||
void PreDeletedCheck(XList<CK2::CK_ID>& objarray, CK2::CKContext* ctx) {
|
||||
if (ctx == nullptr) return;
|
||||
std::erase_if(objarray, [ctx](const CK2::CK_ID& item) -> bool {
|
||||
return GeneralXArrayCheck_ItemCheck<CK2::CK_ID, true>(item, ctx);
|
||||
return GenericXArrayCheck_ItemCheck<CK2::CK_ID, true>(item, ctx);
|
||||
});
|
||||
}
|
||||
|
||||
void PostDeletedCheck(XList<CK2::CK_ID>& objarray, CK2::CKContext* ctx) {
|
||||
if (ctx == nullptr) return;
|
||||
std::erase_if(objarray, [ctx](const CK2::CK_ID& item) -> bool {
|
||||
return GeneralXArrayCheck_ItemCheck<CK2::CK_ID, false>(item, ctx);
|
||||
return GenericXArrayCheck_ItemCheck<CK2::CK_ID, false>(item, ctx);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -153,14 +153,14 @@ namespace LibCmo::XContainer {
|
||||
void PreDeletedCheck(XObjectPointerArray& objarray, CK2::CKContext* ctx) {
|
||||
if (ctx == nullptr) return;
|
||||
std::erase_if(objarray, [ctx](CK2::ObjImpls::CKObject* const& item) -> bool {
|
||||
return GeneralXArrayCheck_ItemCheck<CK2::ObjImpls::CKObject*, true>(item, ctx);
|
||||
return GenericXArrayCheck_ItemCheck<CK2::ObjImpls::CKObject*, true>(item, ctx);
|
||||
});
|
||||
}
|
||||
|
||||
void PostDeletedCheck(XObjectPointerArray& objarray, CK2::CKContext* ctx) {
|
||||
if (ctx == nullptr) return;
|
||||
std::erase_if(objarray, [ctx](CK2::ObjImpls::CKObject* const& item) -> bool {
|
||||
return GeneralXArrayCheck_ItemCheck<CK2::ObjImpls::CKObject*, false>(item, ctx);
|
||||
return GenericXArrayCheck_ItemCheck<CK2::ObjImpls::CKObject*, false>(item, ctx);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -168,14 +168,14 @@ namespace LibCmo::XContainer {
|
||||
void PreDeletedCheck(XList<CK2::ObjImpls::CKObject*>& objarray, CK2::CKContext* ctx) {
|
||||
if (ctx == nullptr) return;
|
||||
std::erase_if(objarray, [ctx](CK2::ObjImpls::CKObject* const& item) -> bool {
|
||||
return GeneralXArrayCheck_ItemCheck<CK2::ObjImpls::CKObject*, true>(item, ctx);
|
||||
return GenericXArrayCheck_ItemCheck<CK2::ObjImpls::CKObject*, true>(item, ctx);
|
||||
});
|
||||
}
|
||||
|
||||
void PostDeletedCheck(XList<CK2::ObjImpls::CKObject*>& objarray, CK2::CKContext* ctx) {
|
||||
if (ctx == nullptr) return;
|
||||
std::erase_if(objarray, [ctx](CK2::ObjImpls::CKObject* const& item) -> bool {
|
||||
return GeneralXArrayCheck_ItemCheck<CK2::ObjImpls::CKObject*, false>(item, ctx);
|
||||
return GenericXArrayCheck_ItemCheck<CK2::ObjImpls::CKObject*, false>(item, ctx);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -114,33 +114,6 @@ namespace Unvirt::StructFmt {
|
||||
std::cout << strop::printf(u8"Page %" PRIuSIZET " of %" PRIuSIZET, page + 1, pager.GetMaxPage() + 1) << std::endl;
|
||||
}
|
||||
|
||||
//template<class T>
|
||||
//static void GeneralPrintList(
|
||||
// const std::vector<T>& data, size_t page, size_t pageitems,
|
||||
// std::function<void()> printHdrFct, std::function<void(size_t, const T&)> printEntryFct) {
|
||||
|
||||
// // check page overflow
|
||||
// if (page * pageitems >= data.size()) {
|
||||
// console::write_line(YYCC_COLOR_LIGHT_RED(u8"Page out of range."));
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // calc page data
|
||||
// size_t fulllen = data.size(),
|
||||
// startpos = page * pageitems,
|
||||
// fullpage = (fulllen + (pageitems - 1)) / pageitems; // to solve `fulllen / pageitems` empty page issue. like CKStateChunk::GetCeilDwordSize function (+3 /4 to get DWORD size).
|
||||
|
||||
// // print header
|
||||
// printHdrFct();
|
||||
|
||||
// // print body
|
||||
// for (size_t counter = startpos; counter < fulllen && (counter - startpos) < pageitems; ++counter) {
|
||||
// printEntryFct(counter, data[counter]);
|
||||
// }
|
||||
|
||||
// console::format_line(u8"Page %" PRIuSIZET " of %" PRIuSIZET, page + 1, fullpage);
|
||||
//}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Object Printer
|
||||
|
||||
Reference in New Issue
Block a user