diff --git a/BMap/CMakeLists.txt b/BMap/CMakeLists.txt index e401075..eb89c32 100644 --- a/BMap/CMakeLists.txt +++ b/BMap/CMakeLists.txt @@ -18,8 +18,6 @@ FILES target_include_directories(BMap PRIVATE "${CMAKE_CURRENT_LIST_DIR}" - YYCC::YYCCommonplace - LibCmo ) # Setup linked library infomation target_link_libraries(BMap @@ -52,6 +50,6 @@ PRIVATE # Install BMap only on Release mode install(TARGETS BMap - CONFIGURATIONS Release + CONFIGURATIONS Release RelWithDebInfo MinSizeRel RUNTIME DESTINATION ${YYCC_INSTALL_BIN_PATH} ) diff --git a/CMake/custom_import_yycc.cmake b/CMake/custom_import_yycc.cmake index 3e71f36..a9db286 100644 --- a/CMake/custom_import_yycc.cmake +++ b/CMake/custom_import_yycc.cmake @@ -6,6 +6,10 @@ endif() # Find YYCC library # It will produce YYCC::YYCCommonplace target for including and linking. -find_package(YYCCommonplace REQUIRED - HINTS ${YYCC_PATH} NO_DEFAULT_PATH -) +# +# Please note we MUST set CMake variable YYCCommonplace_ROOT to make sure CMake can found YYCC in out given path. +# The cache status of YYCCommonplace_ROOT is doesn't matter. +# CMake will throw error if we use HINTS feature in find_package to find YYCC. +set(YYCCommonplace_ROOT ${YYCC_PATH} CACHE PATH +"The path to YYCC CMake distribution installation path.") +find_package(YYCCommonplace REQUIRED) diff --git a/Documents/CMakeLists.txt b/Documents/CMakeLists.txt index c518824..0251377 100644 --- a/Documents/CMakeLists.txt +++ b/Documents/CMakeLists.txt @@ -14,5 +14,6 @@ add_custom_target (NeMoDocuments # Install built documentation install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html + CONFIGURATIONS Release RelWithDebInfo MinSizeRel DESTINATION ${NEMO_INSTALL_DOC_PATH} ) diff --git a/LibCmo/CK2/CKBitmapData.cpp b/LibCmo/CK2/CKBitmapData.cpp index 77ba414..e10c7b7 100644 --- a/LibCmo/CK2/CKBitmapData.cpp +++ b/LibCmo/CK2/CKBitmapData.cpp @@ -521,7 +521,7 @@ namespace LibCmo::CK2 { m_Slots.resize(count); if (count == 0) { - EnumsHelper::Add(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_INVALID); + YYCC::EnumHelper::Add(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_INVALID); } } @@ -535,8 +535,8 @@ namespace LibCmo::CK2 { m_CurrentSlot = slot; // NOTE: idk what the fuck this is. just interpter the IDA decompiled code. - if (EnumsHelper::Has(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_CUBEMAP)) { - EnumsHelper::Add(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_FORCERESTORE); + if (YYCC::EnumHelper::Has(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_CUBEMAP)) { + YYCC::EnumHelper::Add(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_FORCERESTORE); } } @@ -660,14 +660,14 @@ namespace LibCmo::CK2 { // but we decide split the flag settings and slot. // User should set slot count manually. if (is_cube) { - EnumsHelper::Add(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_CUBEMAP); + YYCC::EnumHelper::Add(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_CUBEMAP); } else { - EnumsHelper::Rm(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_CUBEMAP); + YYCC::EnumHelper::Remove(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_CUBEMAP); } } bool CKBitmapData::IsCubeMap() const { - return EnumsHelper::Has(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_CUBEMAP); + return YYCC::EnumHelper::Has(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_CUBEMAP); } const CKBitmapProperties& CKBitmapData::GetSaveFormat() const { @@ -688,14 +688,14 @@ namespace LibCmo::CK2 { void CKBitmapData::SetTransparent(bool Transparency) { if (Transparency) { - EnumsHelper::Add(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_TRANSPARENT); + YYCC::EnumHelper::Add(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_TRANSPARENT); } else { - EnumsHelper::Rm(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_TRANSPARENT); + YYCC::EnumHelper::Remove(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_TRANSPARENT); } } bool CKBitmapData::IsTransparent() const { - return EnumsHelper::Has(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_TRANSPARENT); + return YYCC::EnumHelper::Has(m_BitmapFlags, CK_BITMAPDATA_FLAGS::CKBITMAPDATA_TRANSPARENT); } void CKBitmapData::SetTransparentColor(CKDWORD col) { diff --git a/LibCmo/CK2/CKFileReader.cpp b/LibCmo/CK2/CKFileReader.cpp index 772c5d9..d02f413 100644 --- a/LibCmo/CK2/CKFileReader.cpp +++ b/LibCmo/CK2/CKFileReader.cpp @@ -205,8 +205,8 @@ namespace LibCmo::CK2 { std::string name_conv; // ========== compress feature process ========== - if (EnumsHelper::Has(this->m_FileInfo.FileWriteMode, CK_FILE_WRITEMODE::CKFILE_CHUNKCOMPRESSED_OLD) || - EnumsHelper::Has(this->m_FileInfo.FileWriteMode, CK_FILE_WRITEMODE::CKFILE_WHOLECOMPRESSED)) { + if (YYCC::EnumHelper::Has(this->m_FileInfo.FileWriteMode, CK_FILE_WRITEMODE::CKFILE_CHUNKCOMPRESSED_OLD) || + YYCC::EnumHelper::Has(this->m_FileInfo.FileWriteMode, CK_FILE_WRITEMODE::CKFILE_WHOLECOMPRESSED)) { void* decomp_buffer = CKUnPackData(this->m_FileInfo.DataUnPackSize, parser->GetPtr(), this->m_FileInfo.DataPackSize); if (decomp_buffer != nullptr) { diff --git a/LibCmo/CK2/CKFileWriter.cpp b/LibCmo/CK2/CKFileWriter.cpp index 892687e..a176a18 100644 --- a/LibCmo/CK2/CKFileWriter.cpp +++ b/LibCmo/CK2/CKFileWriter.cpp @@ -216,8 +216,8 @@ namespace LibCmo::CK2 { } // compress header if needed - if (EnumsHelper::Has(fileWriteMode, CK_FILE_WRITEMODE::CKFILE_CHUNKCOMPRESSED_OLD) || - EnumsHelper::Has(fileWriteMode, CK_FILE_WRITEMODE::CKFILE_WHOLECOMPRESSED)) { + if (YYCC::EnumHelper::Has(fileWriteMode, CK_FILE_WRITEMODE::CKFILE_CHUNKCOMPRESSED_OLD) || + YYCC::EnumHelper::Has(fileWriteMode, CK_FILE_WRITEMODE::CKFILE_WHOLECOMPRESSED)) { CKDWORD comp_buf_size = 0; void* comp_buffer = CKPackData(hdrparser->GetBase(), hdrparser->GetSize(), comp_buf_size, m_Ctx->GetCompressionLevel()); @@ -263,8 +263,8 @@ namespace LibCmo::CK2 { } // compress header if needed - if (EnumsHelper::Has(fileWriteMode, CK_FILE_WRITEMODE::CKFILE_CHUNKCOMPRESSED_OLD) || - EnumsHelper::Has(fileWriteMode, CK_FILE_WRITEMODE::CKFILE_WHOLECOMPRESSED)) { + if (YYCC::EnumHelper::Has(fileWriteMode, CK_FILE_WRITEMODE::CKFILE_CHUNKCOMPRESSED_OLD) || + YYCC::EnumHelper::Has(fileWriteMode, CK_FILE_WRITEMODE::CKFILE_WHOLECOMPRESSED)) { CKDWORD comp_buf_size = 0; void* comp_buffer = CKPackData(datparser->GetBase(), datparser->GetSize(), comp_buf_size, m_Ctx->GetCompressionLevel()); diff --git a/LibCmo/CK2/CKStateChunkOthers.cpp b/LibCmo/CK2/CKStateChunkOthers.cpp index d68dc18..a7daf62 100644 --- a/LibCmo/CK2/CKStateChunkOthers.cpp +++ b/LibCmo/CK2/CKStateChunkOthers.cpp @@ -419,23 +419,23 @@ namespace LibCmo::CK2 { std::memcpy(this->m_pData, dwbuf + bufpos, sizeof(CKDWORD) * this->m_DataDwSize); bufpos += this->m_DataDwSize; } - if (!EnumsHelper::Has(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_FILE)) { + if (!YYCC::EnumHelper::Has(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_FILE)) { // forced no bind file this->m_BindFile = nullptr; } - if (EnumsHelper::Has(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_IDS)) { + if (YYCC::EnumHelper::Has(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_IDS)) { this->m_ObjectList.resize(dwbuf[bufpos]); bufpos += 1u; std::memcpy(this->m_ObjectList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ObjectList.size()); bufpos += this->m_ObjectList.size(); } - if (EnumsHelper::Has(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_CHN)) { + if (YYCC::EnumHelper::Has(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_CHN)) { this->m_ChunkList.resize(dwbuf[bufpos]); bufpos += 1u; std::memcpy(this->m_ChunkList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ChunkList.size()); bufpos += this->m_ChunkList.size(); } - if (EnumsHelper::Has(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_MAN)) { + if (YYCC::EnumHelper::Has(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_MAN)) { this->m_ManagerList.resize(dwbuf[bufpos]); bufpos += 1u; std::memcpy(this->m_ManagerList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ManagerList.size()); @@ -459,19 +459,19 @@ namespace LibCmo::CK2 { if (!m_ObjectList.empty()) { size += CKSizeof(CKDWORD) * static_cast(m_ObjectList.size()) + sizeof(CKDWORD); - EnumsHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_IDS); + YYCC::EnumHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_IDS); } if (!m_ChunkList.empty()) { size += CKSizeof(CKDWORD) * static_cast(m_ChunkList.size()) + sizeof(CKDWORD); - EnumsHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_CHN); + YYCC::EnumHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_CHN); } if (!m_ManagerList.empty()) { size += CKSizeof(CKDWORD) * static_cast(m_ManagerList.size()) + sizeof(CKDWORD); - EnumsHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_MAN); + YYCC::EnumHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_MAN); } if (this->m_BindFile != nullptr) { - EnumsHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_FILE); + YYCC::EnumHelper::Add(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_FILE); } // if buffer provided, write it diff --git a/LibCmo/CK2/MgrImpls/CKObjectManager.cpp b/LibCmo/CK2/MgrImpls/CKObjectManager.cpp index d282e16..5f5623a 100644 --- a/LibCmo/CK2/MgrImpls/CKObjectManager.cpp +++ b/LibCmo/CK2/MgrImpls/CKObjectManager.cpp @@ -86,7 +86,7 @@ namespace LibCmo::CK2::MgrImpls { // set to be deleted CK_OBJECT_FLAGS objflag = obj->GetObjectFlags(); - EnumsHelper::Add(objflag, CK_OBJECT_FLAGS::CK_OBJECT_TOBEDELETED); + YYCC::EnumHelper::Add(objflag, CK_OBJECT_FLAGS::CK_OBJECT_TOBEDELETED); obj->SetObjectFlags(objflag); // collect class id diff --git a/LibCmo/CK2/ObjImpls/CK3dEntity.cpp b/LibCmo/CK2/ObjImpls/CK3dEntity.cpp index 05ea1ab..f34960c 100644 --- a/LibCmo/CK2/ObjImpls/CK3dEntity.cpp +++ b/LibCmo/CK2/ObjImpls/CK3dEntity.cpp @@ -9,12 +9,12 @@ namespace LibCmo::CK2::ObjImpls { CKRenderObject(ctx, ckid, name), m_PotentialMeshes(), m_CurrentMesh(nullptr), m_WorldMatrix(), m_ZOrder(0), - m_MoveableFlags(EnumsHelper::Merge({ + m_MoveableFlags(YYCC::EnumHelper::Merge( VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_PICKABLE, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_RENDERCHANNELS, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_INVERSEWORLDMATVALID - })), + )), m_3dEntityFlags(static_cast(0)) {} CK3dEntity::~CK3dEntity() {} @@ -53,15 +53,15 @@ namespace LibCmo::CK2::ObjImpls { // regulate self flag again // MARK: originally we should check parent here. // but we do not support parent and hierarchy feature, so we simply remove flag - EnumsHelper::Rm(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PARENTVALID); + YYCC::EnumHelper::Remove(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PARENTVALID); // MARK: originally we should check grouped into CKPlace here. // but we do not support CKPlace, so we simply remove this flag - EnumsHelper::Rm(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PLACEVALID); + YYCC::EnumHelper::Remove(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PLACEVALID); // check z-order, if not zero, save it if (m_ZOrder != 0) { - EnumsHelper::Add(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_ZORDERVALID); + YYCC::EnumHelper::Add(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_ZORDERVALID); } else { - EnumsHelper::Rm(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_ZORDERVALID); + YYCC::EnumHelper::Remove(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_ZORDERVALID); } // write 2 flags @@ -94,7 +94,7 @@ namespace LibCmo::CK2::ObjImpls { if (!suc) return false; // backup moveable flags - bool hasWorldAligned = EnumsHelper::Has(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_WORLDALIGNED); + bool hasWorldAligned = YYCC::EnumHelper::Has(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_WORLDALIGNED); // MARK: object animation is skipped @@ -132,11 +132,11 @@ namespace LibCmo::CK2::ObjImpls { chunk->ReadStruct(m_3dEntityFlags); chunk->ReadStruct(m_MoveableFlags); // remove some properties - EnumsHelper::Rm(m_3dEntityFlags, EnumsHelper::Merge({ + YYCC::EnumHelper::Remove(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_UPDATELASTFRAME, CK_3DENTITY_FLAGS::CK_3DENTITY_RESERVED0 - })); - EnumsHelper::Rm(m_MoveableFlags, EnumsHelper::Merge({ + ); + YYCC::EnumHelper::Remove(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_RESERVED2, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_STENCILONLY, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_DONTUPDATEFROMPARENT, @@ -145,13 +145,13 @@ namespace LibCmo::CK2::ObjImpls { VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_BOXVALID, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_USERBOX, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_UPTODATE - })); + ); if (hasWorldAligned) { - EnumsHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_WORLDALIGNED); + YYCC::EnumHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_WORLDALIGNED); } // if order render first - if (EnumsHelper::Has(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_RENDERFIRST)) { + if (YYCC::EnumHelper::Has(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_RENDERFIRST)) { m_ZOrder = 10000; } @@ -171,47 +171,47 @@ namespace LibCmo::CK2::ObjImpls { VxMath::VxVector3 crossProduct = VxMath::NSVxVector::CrossProduct(col0, col1); CKFLOAT dotProduct = VxMath::NSVxVector::DotProduct(crossProduct, col2); if (dotProduct >= 0.0f) { - EnumsHelper::Rm(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_INDIRECTMATRIX); + YYCC::EnumHelper::Remove(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_INDIRECTMATRIX); } else { - EnumsHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_INDIRECTMATRIX); + YYCC::EnumHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_INDIRECTMATRIX); } // copy visible data // process direct visible - if (EnumsHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE)) { - EnumsHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE); + if (YYCC::EnumHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE)) { + YYCC::EnumHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE); } else { - EnumsHelper::Rm(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE); + YYCC::EnumHelper::Remove(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE); } // process indirect visible - if (EnumsHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE)) { - EnumsHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HIERARCHICALHIDE); + if (YYCC::EnumHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE)) { + YYCC::EnumHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HIERARCHICALHIDE); } else { - EnumsHelper::Rm(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HIERARCHICALHIDE); + YYCC::EnumHelper::Remove(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HIERARCHICALHIDE); } // read associated CKPlace - if (EnumsHelper::Has(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PLACEVALID)) { + if (YYCC::EnumHelper::Has(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PLACEVALID)) { // MARK: we drop the support of CKPlace. // so we just read it and skip it. CK_ID placeid; chunk->ReadObjectID(placeid); // and remove this flag - EnumsHelper::Rm(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PLACEVALID); + YYCC::EnumHelper::Remove(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PLACEVALID); } // read parent - if (EnumsHelper::Has(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PARENTVALID)) { + if (YYCC::EnumHelper::Has(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PARENTVALID)) { // MAKR: we drop the support of parent and the whole 3dentity hierarchy system // we ignore this field. CK_ID parentid; chunk->ReadObjectID(parentid); // and remove this flag - EnumsHelper::Rm(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PARENTVALID); + YYCC::EnumHelper::Remove(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PARENTVALID); } // read priority (non-zero zorder) - if (EnumsHelper::Has(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_ZORDERVALID)) { + if (YYCC::EnumHelper::Has(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_ZORDERVALID)) { chunk->ReadStruct(m_ZOrder); } @@ -227,16 +227,16 @@ namespace LibCmo::CK2::ObjImpls { void CK3dEntity::Show(CK_OBJECT_SHOWOPTION show) { CKObject::Show(show); - EnumsHelper::Rm(m_MoveableFlags, EnumsHelper::Merge({ + YYCC::EnumHelper::Remove(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE, - VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HIERARCHICALHIDE, - })); + VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HIERARCHICALHIDE + ); switch (show) { case CK_OBJECT_SHOWOPTION::CKSHOW: - EnumsHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE); + YYCC::EnumHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE); break; case CK_OBJECT_SHOWOPTION::CKHIERARCHICALHIDE: - EnumsHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HIERARCHICALHIDE); + YYCC::EnumHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HIERARCHICALHIDE); break; case CK_OBJECT_SHOWOPTION::CKHIDE: break; diff --git a/LibCmo/CK2/ObjImpls/CKMesh.cpp b/LibCmo/CK2/ObjImpls/CKMesh.cpp index b4c3901..08481be 100644 --- a/LibCmo/CK2/ObjImpls/CKMesh.cpp +++ b/LibCmo/CK2/ObjImpls/CKMesh.cpp @@ -21,12 +21,12 @@ namespace LibCmo::CK2::ObjImpls { m_LineCount(0), m_LineIndices(), // init flags - m_Flags(EnumsHelper::Merge({ + m_Flags(YYCC::EnumHelper::Merge( VxMath::VXMESH_FLAGS::VXMESH_VISIBLE, VxMath::VXMESH_FLAGS::VXMESH_RENDERCHANNELS - })) { + )) { // set visible in default - EnumsHelper::Add(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE); + YYCC::EnumHelper::Add(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE); } CKMesh::~CKMesh() {} @@ -145,7 +145,7 @@ namespace LibCmo::CK2::ObjImpls { rawbuf += CKSizeof(CKDWORD); // write vertex position - if (!EnumsHelper::Has(saveflags, VertexSaveFlags::NoPos)) { + if (!YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::NoPos)) { CKDWORD consumed = CKSizeof(VxMath::VxVector3) * vtxCount; std::memcpy(rawbuf, m_VertexPosition.data(), consumed); rawbuf += consumed; @@ -154,7 +154,7 @@ namespace LibCmo::CK2::ObjImpls { // write color and specular color { CKDWORD consumed = 0; - if (!EnumsHelper::Has(saveflags, VertexSaveFlags::SingleColor)) { + if (!YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::SingleColor)) { consumed = CKSizeof(CKDWORD) * vtxCount; } else { consumed = CKSizeof(CKDWORD); @@ -165,7 +165,7 @@ namespace LibCmo::CK2::ObjImpls { } { CKDWORD consumed = 0; - if (!EnumsHelper::Has(saveflags, VertexSaveFlags::SingleSpecularColor)) { + if (!YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::SingleSpecularColor)) { consumed = CKSizeof(CKDWORD) * vtxCount; } else { consumed = CKSizeof(CKDWORD); @@ -176,7 +176,7 @@ namespace LibCmo::CK2::ObjImpls { } // write normal - if (!EnumsHelper::Has(saveflags, VertexSaveFlags::NoNormal)) { + if (!YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::NoNormal)) { CKDWORD consumed = CKSizeof(VxMath::VxVector3) * vtxCount; std::memcpy(rawbuf, m_VertexNormal.data(), consumed); rawbuf += consumed; @@ -185,7 +185,7 @@ namespace LibCmo::CK2::ObjImpls { // write uv { CKDWORD consumed = 0; - if (!EnumsHelper::Has(saveflags, VertexSaveFlags::SingleUV)) { + if (!YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::SingleUV)) { consumed = CKSizeof(VxMath::VxVector2) * vtxCount; } else { consumed = CKSizeof(VxMath::VxVector2); @@ -229,13 +229,13 @@ namespace LibCmo::CK2::ObjImpls { // read flag if (chunk->SeekIdentifier(CK_STATESAVEFLAGS_MESH::CK_STATESAVE_MESHFLAGS)) { chunk->ReadStruct(m_Flags); - EnumsHelper::Mask(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_ALLFLAGS); + YYCC::EnumHelper::Mask(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_ALLFLAGS); // I don't know why, just interpter the IDA code. - EnumsHelper::Rm(m_Flags, EnumsHelper::Merge({ + YYCC::EnumHelper::Remove(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_BOUNDINGUPTODATE, VxMath::VXMESH_FLAGS::VXMESH_OPTIMIZED - })); + ); } // read material slots @@ -285,14 +285,14 @@ namespace LibCmo::CK2::ObjImpls { const CKBYTE* rawbuf = static_cast(buf.get()); // copy position if it have - if (!EnumsHelper::Has(saveflags, VertexSaveFlags::NoPos)) { + if (!YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::NoPos)) { CKDWORD consumed = CKSizeof(VxMath::VxVector3) * vertexCount; std::memcpy(m_VertexPosition.data(), rawbuf, consumed); rawbuf += consumed; } // copy color or apply single color - if (!EnumsHelper::Has(saveflags, VertexSaveFlags::SingleColor)) { + if (!YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::SingleColor)) { CKDWORD consumed = CKSizeof(CKDWORD) * vertexCount; std::memcpy(m_VertexColor.data(), rawbuf, consumed); rawbuf += consumed; @@ -309,7 +309,7 @@ namespace LibCmo::CK2::ObjImpls { } // copy specular color or apply a single color - if (!EnumsHelper::Has(saveflags, VertexSaveFlags::SingleSpecularColor)) { + if (!YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::SingleSpecularColor)) { CKDWORD consumed = CKSizeof(CKDWORD) * vertexCount; std::memcpy(m_VertexSpecularColor.data(), rawbuf, consumed); rawbuf += consumed; @@ -326,14 +326,14 @@ namespace LibCmo::CK2::ObjImpls { } // copy normals if it has - if (!EnumsHelper::Has(saveflags, VertexSaveFlags::NoNormal)) { + if (!YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::NoNormal)) { CKDWORD consumed = CKSizeof(VxMath::VxVector3) * vertexCount; std::memcpy(m_VertexNormal.data(), rawbuf, consumed); rawbuf += consumed; } // copy uv or apply single uv - if (!EnumsHelper::Has(saveflags, VertexSaveFlags::SingleUV)) { + if (!YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::SingleUV)) { CKDWORD consumed = CKSizeof(VxMath::VxVector2) * vertexCount; std::memcpy(m_VertexUV.data(), rawbuf, consumed); rawbuf += consumed; @@ -407,7 +407,7 @@ namespace LibCmo::CK2::ObjImpls { } // build normals - if (EnumsHelper::Has(saveflags, VertexSaveFlags::NoNormal)) { + if (YYCC::EnumHelper::Has(saveflags, VertexSaveFlags::NoNormal)) { BuildNormals(); } else { BuildFaceNormals(); @@ -425,9 +425,9 @@ namespace LibCmo::CK2::ObjImpls { CKObject::Show(show); if (show == CK_OBJECT_SHOWOPTION::CKSHOW) { - EnumsHelper::Add(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_VISIBLE); + YYCC::EnumHelper::Add(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_VISIBLE); } else { - EnumsHelper::Rm(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_VISIBLE); + YYCC::EnumHelper::Remove(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_VISIBLE); } } @@ -449,15 +449,15 @@ namespace LibCmo::CK2::ObjImpls { m_Flags = flags; // sync visibility to CKObject layer. - if (EnumsHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_VISIBLE)) { - EnumsHelper::Add(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE); + if (YYCC::EnumHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_VISIBLE)) { + YYCC::EnumHelper::Add(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE); } else { - EnumsHelper::Rm(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE); + YYCC::EnumHelper::Remove(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE); } } VxMath::VXMESH_LITMODE CKMesh::GetLitMode() const { - if (EnumsHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_PRELITMODE)) { + if (YYCC::EnumHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_PRELITMODE)) { return VxMath::VXMESH_LITMODE::VX_PRELITMESH; } else { return VxMath::VXMESH_LITMODE::VX_LITMESH; @@ -467,10 +467,10 @@ namespace LibCmo::CK2::ObjImpls { void CKMesh::SetLitMode(VxMath::VXMESH_LITMODE mode) { switch (mode) { case VxMath::VXMESH_LITMODE::VX_PRELITMESH: - EnumsHelper::Add(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_PRELITMODE); + YYCC::EnumHelper::Add(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_PRELITMODE); break; case VxMath::VXMESH_LITMODE::VX_LITMESH: - EnumsHelper::Rm(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_PRELITMODE); + YYCC::EnumHelper::Remove(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_PRELITMODE); break; } } @@ -478,51 +478,51 @@ namespace LibCmo::CK2::ObjImpls { VxMath::VXTEXTURE_WRAPMODE CKMesh::GetWrapMode() const { VxMath::VXTEXTURE_WRAPMODE ret = VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_NONE; - if (EnumsHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPU)) { - EnumsHelper::Add(ret, VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_U); + if (YYCC::EnumHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPU)) { + YYCC::EnumHelper::Add(ret, VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_U); } - if (EnumsHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPV)) { - EnumsHelper::Add(ret, VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_V); + if (YYCC::EnumHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPV)) { + YYCC::EnumHelper::Add(ret, VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_V); } return ret; } void CKMesh::SetWrapMode(VxMath::VXTEXTURE_WRAPMODE mode) { - if (EnumsHelper::Has(mode, VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_U)) { - EnumsHelper::Add(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPU); + if (YYCC::EnumHelper::Has(mode, VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_U)) { + YYCC::EnumHelper::Add(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPU); } else { - EnumsHelper::Rm(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPU); + YYCC::EnumHelper::Remove(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPU); } - if (EnumsHelper::Has(mode, VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_V)) { - EnumsHelper::Add(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPV); + if (YYCC::EnumHelper::Has(mode, VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_V)) { + YYCC::EnumHelper::Add(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPV); } else { - EnumsHelper::Rm(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPV); + YYCC::EnumHelper::Remove(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_WRAPV); } } CKMesh::VertexSaveFlags CKMesh::GenerateSaveFlags() { // set to initial status - VertexSaveFlags saveflags = EnumsHelper::Merge({ + VertexSaveFlags saveflags = YYCC::EnumHelper::Merge( VertexSaveFlags::SingleColor, VertexSaveFlags::SingleSpecularColor, VertexSaveFlags::NoNormal, VertexSaveFlags::SingleUV - }); + ); // check no pos // if position is generated, skip saving position - if (EnumsHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_PROCEDURALPOS)) { - EnumsHelper::Add(saveflags, VertexSaveFlags::NoPos); + if (YYCC::EnumHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_PROCEDURALPOS)) { + YYCC::EnumHelper::Add(saveflags, VertexSaveFlags::NoPos); } // check uv // if uv is not generated and all uv are not the same value, remove single uv - if (!EnumsHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_PROCEDURALUV)) { + if (!YYCC::EnumHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_PROCEDURALUV)) { for (const auto& uv : m_VertexUV) { if (uv != m_VertexUV.front()) { - EnumsHelper::Rm(saveflags, VertexSaveFlags::SingleUV); + YYCC::EnumHelper::Remove(saveflags, VertexSaveFlags::SingleUV); break; } } @@ -532,19 +532,19 @@ namespace LibCmo::CK2::ObjImpls { // if all color are not the same value, remove single color for (const auto& col : m_VertexColor) { if (col != m_VertexColor.front()) { - EnumsHelper::Rm(saveflags, VertexSaveFlags::SingleColor); + YYCC::EnumHelper::Remove(saveflags, VertexSaveFlags::SingleColor); break; } } for (const auto& col : m_VertexSpecularColor) { if (col != m_VertexSpecularColor.front()) { - EnumsHelper::Rm(saveflags, VertexSaveFlags::SingleSpecularColor); + YYCC::EnumHelper::Remove(saveflags, VertexSaveFlags::SingleSpecularColor); break; } } // if normal not changed, and position is not generated, we should consider whether we need save normal (step into if) - if (!EnumsHelper::Has(m_Flags, EnumsHelper::Merge({ VxMath::VXMESH_FLAGS::VXMESH_NORMAL_CHANGED, VxMath::VXMESH_FLAGS::VXMESH_PROCEDURALPOS }))) { + if (!YYCC::EnumHelper::Has(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_NORMAL_CHANGED, VxMath::VXMESH_FLAGS::VXMESH_PROCEDURALPOS)) { // MARK: we should build face normal first // then we build vertex normal like BuildNormals. // then, we compare the difference between the generated normals and user specified normals, by simply using operator- (userNml - generatedNml) and abs the result. @@ -581,7 +581,7 @@ namespace LibCmo::CK2::ObjImpls { accnml /= static_cast(m_VertexCount); if (accnml.Length() > 0.001f) { // too large difference, we need save normal - EnumsHelper::Rm(saveflags, VertexSaveFlags::NoNormal); + YYCC::EnumHelper::Remove(saveflags, VertexSaveFlags::NoNormal); } } diff --git a/LibCmo/CK2/ObjImpls/CKObject.cpp b/LibCmo/CK2/ObjImpls/CKObject.cpp index 7bdaec0..5373779 100644 --- a/LibCmo/CK2/ObjImpls/CKObject.cpp +++ b/LibCmo/CK2/ObjImpls/CKObject.cpp @@ -32,7 +32,7 @@ namespace LibCmo::CK2::ObjImpls { m_ObjectFlags = flags; } bool CKObject::IsToBeDeleted() const { - return EnumsHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_TOBEDELETED); + return YYCC::EnumHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_TOBEDELETED); } CKContext* CKObject::GetCKContext() const { return m_Context; @@ -51,10 +51,10 @@ namespace LibCmo::CK2::ObjImpls { void CKObject::PreSave(CKFileVisitor* file, CKDWORD flags) {} bool CKObject::Save(CKStateChunk* chunk, CKFileVisitor* file, CKDWORD flags) { - if (EnumsHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE)) { + if (YYCC::EnumHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE)) { // if hierarchy hidden chunk->WriteIdentifier(CK_STATESAVEFLAGS_OBJECT::CK_STATESAVE_OBJECTHIERAHIDDEN); - } else if (!EnumsHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE)) { + } else if (!YYCC::EnumHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE)) { // if really hidden chunk->WriteIdentifier(CK_STATESAVEFLAGS_OBJECT::CK_STATESAVE_OBJECTHIDDEN); } @@ -65,18 +65,20 @@ namespace LibCmo::CK2::ObjImpls { bool CKObject::Load(CKStateChunk* chunk, CKFileVisitor* file) { if (chunk->SeekIdentifier(CK_STATESAVEFLAGS_OBJECT::CK_STATESAVE_OBJECTHIDDEN)) { - EnumsHelper::Rm(this->m_ObjectFlags, - EnumsHelper::Merge({ CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE })); + YYCC::EnumHelper::Remove(this->m_ObjectFlags, + CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE, + CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE + ); } else { if (chunk->SeekIdentifier(CK_STATESAVEFLAGS_OBJECT::CK_STATESAVE_OBJECTHIERAHIDDEN)) { // != 0 - EnumsHelper::Rm(this->m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE); - EnumsHelper::Add(this->m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE); + YYCC::EnumHelper::Remove(this->m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE); + YYCC::EnumHelper::Add(this->m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE); } else { // == 0 - EnumsHelper::Add(this->m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE); - EnumsHelper::Rm(this->m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE); + YYCC::EnumHelper::Add(this->m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE); + YYCC::EnumHelper::Remove(this->m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE); } } @@ -89,17 +91,17 @@ namespace LibCmo::CK2::ObjImpls { void CKObject::Show(CK_OBJECT_SHOWOPTION show) { // clear all visible data of object flags - EnumsHelper::Rm(m_ObjectFlags, EnumsHelper::Merge({ + YYCC::EnumHelper::Remove(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE - })); + ); switch (show) { case CK_OBJECT_SHOWOPTION::CKSHOW: - EnumsHelper::Add(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE); + YYCC::EnumHelper::Add(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE); break; case CK_OBJECT_SHOWOPTION::CKHIERARCHICALHIDE: - EnumsHelper::Add(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE); + YYCC::EnumHelper::Add(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE); break; case CK_OBJECT_SHOWOPTION::CKHIDE: return; @@ -107,7 +109,7 @@ namespace LibCmo::CK2::ObjImpls { } bool CKObject::IsVisible() const { - return EnumsHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE); + return YYCC::EnumHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE); } diff --git a/LibCmo/CMakeLists.txt b/LibCmo/CMakeLists.txt index d3a450e..980693b 100644 --- a/LibCmo/CMakeLists.txt +++ b/LibCmo/CMakeLists.txt @@ -86,19 +86,15 @@ target_include_directories(LibCmo PUBLIC "$" "$" -PRIVATE - YYCC::YYCCommonplace - ZLIB::ZLIB - stb::stb-image ) target_link_libraries(LibCmo -PRIVATE +PUBLIC YYCC::YYCCommonplace +PRIVATE ZLIB::ZLIB stb::stb-image ) if (NOT WIN32) - target_include_directories(LibCmo PRIVATE Iconv::Iconv) target_link_libraries(LibCmo PRIVATE Iconv::Iconv) endif () # Setup C++ standard diff --git a/LibCmo/VTEncoding.cpp b/LibCmo/VTEncoding.cpp index 3da1061..32ed067 100644 --- a/LibCmo/VTEncoding.cpp +++ b/LibCmo/VTEncoding.cpp @@ -2,10 +2,10 @@ #include #if YYCC_OS == YYCC_OS_WINDOWS -#include +#include #include #include -#include +#include #else #include #endif diff --git a/LibCmo/VTUtils.hpp b/LibCmo/VTUtils.hpp index f8cef0b..20bcfc3 100644 --- a/LibCmo/VTUtils.hpp +++ b/LibCmo/VTUtils.hpp @@ -5,13 +5,14 @@ #error "You must define ONE of LIBCMO_BUILD_DEBUG and LIBCMO_BUILD_RELEASE to indicate build type!" #endif -// Include YYCC helper library +// Include YYCC helper library and check its version #include +#if YYCC_VERCMP_NE(YYCC_VER_MAJOR, YYCC_VER_MINOR, YYCC_VER_PATCH, 1, 3, 0) +#error "YYCC library version is not matched with our expected version. Please check your library configuration." +#endif // Header for this namespace implementation #include -#include -#include /** * @brief The core namespace of LibCmo project. @@ -69,91 +70,4 @@ namespace LibCmo { #pragma endregion - /** - * @brief The namespace for convenient C++ enum class logic operations. - * @details - * C++ enum class statement is a modern way to declare enum in C++. - * But it lack essential logic operations which is commonly used by programmer. - * So we create this helper to resolve this issue. - */ - namespace EnumsHelper { - - /** - * @brief Merge given enum flags like performing e1 | e2 | ... | en - * @tparam TEnum Enum type for processing. - * @param[in] il The list of enum flags to be merged. - * @return The merged enum flag. - */ - template, int> = 0> - constexpr TEnum Merge(std::initializer_list il) { - using ut = std::underlying_type_t; - ut result = 0; - for (auto it = il.begin(); it != il.end(); ++it) { - result |= static_cast(*it); - } - return static_cast(result); - } - - /** - * @brief Reverse given enum flags like performing ~(e) - * @tparam TEnum Enum type for processing. - * @param[in] e The list of enum flags to be inversed. - * @return The inversed enum flag. - */ - template, int> = 0> - constexpr TEnum Inv(TEnum e) { - using ut = std::underlying_type_t; - return static_cast(~(static_cast(e))); - } - - /** - * @brief Remove specified enum flags from given enum flags like performing e1 &= (~e2) - * @tparam TEnum Enum type for processing. - * @param[in,out] e1 The enum flags to be processed. - * @param[in] e2 The enum flag to be removed. - */ - template, int> = 0> - constexpr void Rm(TEnum& e1, TEnum e2) { - using ut = std::underlying_type_t; - e1 = static_cast(static_cast(e1) & static_cast(Inv(e2))); - } - - /** - * @brief Use specified enum flags to mask given enum flags like performing e1 &= e2 - * @tparam TEnum Enum type for processing. - * @param[in,out] e1 The enum flags to be masked. - * @param[in] e2 The mask enum flag. - */ - template, int> = 0> - constexpr void Mask(TEnum& e1, TEnum e2) { - using ut = std::underlying_type_t; - e1 = static_cast(static_cast(e1) & static_cast(e2)); - } - - /** - * @brief Add specified enum flags to given enum flags like performing e1 |= e2 - * @tparam TEnum Enum type for processing. - * @param[in,out] e1 The enum flags to be processed. - * @param[in] e2 The enum flag to be added. - */ - template, int> = 0> - constexpr void Add(TEnum& e1, TEnum e2) { - using ut = std::underlying_type_t; - e1 = static_cast(static_cast(e1) | static_cast(e2)); - } - - /** - * @brief Check whether given enum flags has specified enum flag like performing bool(e & probe) - * @tparam TEnum Enum type for processing. - * @param[in] e1 The enum flags to be checked. - * @param[in] e2 The enum flag for checking. - * @return True if it has, otherwise false. - */ - template, int> = 0> - constexpr bool Has(TEnum e1, TEnum e2) { - using ut = std::underlying_type_t; - return static_cast(static_cast(e1) & static_cast(e2)); - } - } - } diff --git a/LibCmo/VxMath/VxMemoryMappedFile.hpp b/LibCmo/VxMath/VxMemoryMappedFile.hpp index fceab8c..525cd97 100644 --- a/LibCmo/VxMath/VxMemoryMappedFile.hpp +++ b/LibCmo/VxMath/VxMemoryMappedFile.hpp @@ -2,9 +2,9 @@ #include "../VTInternal.hpp" #if YYCC_OS == YYCC_OS_WINDOWS -#include +#include #include -#include +#include #else #include #include diff --git a/Unvirt/AccessibleValue.hpp b/Unvirt/AccessibleValue.hpp index e9f8b9f..0f4abe2 100644 --- a/Unvirt/AccessibleValue.hpp +++ b/Unvirt/AccessibleValue.hpp @@ -61,7 +61,7 @@ namespace Unvirt { } // check flag match - if (LibCmo::EnumsHelper::Has(val, item.first)) { + if (YYCC::EnumHelper::Has(val, item.first)) { // add splittor if it not the first entry if (strl.size() != 0u && splitor != nullptr) { strl += splitor; diff --git a/Unvirt/CMakeLists.txt b/Unvirt/CMakeLists.txt index 95b61a3..26308fd 100644 --- a/Unvirt/CMakeLists.txt +++ b/Unvirt/CMakeLists.txt @@ -23,8 +23,6 @@ FILES target_include_directories(Unvirt PRIVATE "${CMAKE_CURRENT_LIST_DIR}" - YYCC::YYCCommonplace - LibCmo ) # Setup linked library infomation target_link_libraries(Unvirt @@ -53,6 +51,6 @@ PRIVATE # Install Unvirt only on Release mode install(TARGETS Unvirt - CONFIGURATIONS Release + CONFIGURATIONS Release RelWithDebInfo MinSizeRel RUNTIME DESTINATION ${YYCC_INSTALL_BIN_PATH} )