diff --git a/LibCmo/CK2/CKGlobals.cpp b/LibCmo/CK2/CKGlobals.cpp index 2357ba9..ddb6fd6 100644 --- a/LibCmo/CK2/CKGlobals.cpp +++ b/LibCmo/CK2/CKGlobals.cpp @@ -411,11 +411,11 @@ CKClassRegister(cid, parentCid, \ EasyClassReg(ObjImpls::CKBeObject, CK_CLASSID::CKCID_BEOBJECT, CK_CLASSID::CKCID_SCENEOBJECT, "Behavioral Object"); EasyClassRegWithNotify(ObjImpls::CKGroup, CK_CLASSID::CKCID_GROUP, CK_CLASSID::CKCID_BEOBJECT, "Group", { CK_CLASSID::CKCID_BEOBJECT }); EasyClassReg(ObjImpls::CKRenderObject, CK_CLASSID::CKCID_RENDEROBJECT, CK_CLASSID::CKCID_BEOBJECT, "Render Object"); - EasyClassReg(ObjImpls::CK3dEntity, CK_CLASSID::CKCID_3DENTITY, CK_CLASSID::CKCID_RENDEROBJECT, "3D Entity"); + EasyClassRegWithNotify(ObjImpls::CK3dEntity, CK_CLASSID::CKCID_3DENTITY, CK_CLASSID::CKCID_RENDEROBJECT, "3D Entity", { CK_CLASSID::CKCID_MESH }); EasyClassReg(ObjImpls::CK3dObject, CK_CLASSID::CKCID_3DOBJECT, CK_CLASSID::CKCID_3DENTITY, "3D Object"); EasyClassReg(ObjImpls::CKTexture, CK_CLASSID::CKCID_TEXTURE, CK_CLASSID::CKCID_BEOBJECT, "Texture"); - EasyClassReg(ObjImpls::CKMaterial, CK_CLASSID::CKCID_MATERIAL, CK_CLASSID::CKCID_BEOBJECT, "Material"); - EasyClassReg(ObjImpls::CKMesh, CK_CLASSID::CKCID_MESH, CK_CLASSID::CKCID_BEOBJECT, "Mesh"); + EasyClassRegWithNotify(ObjImpls::CKMaterial, CK_CLASSID::CKCID_MATERIAL, CK_CLASSID::CKCID_BEOBJECT, "Material", { CK_CLASSID::CKCID_TEXTURE }); + EasyClassRegWithNotify(ObjImpls::CKMesh, CK_CLASSID::CKCID_MESH, CK_CLASSID::CKCID_BEOBJECT, "Mesh", { CK_CLASSID::CKCID_MATERIAL }); #undef EasyClassReg #undef EasyClassRegWithNotify diff --git a/LibCmo/LibCmo.vcxproj b/LibCmo/LibCmo.vcxproj index 77557ff..e0e8885 100644 --- a/LibCmo/LibCmo.vcxproj +++ b/LibCmo/LibCmo.vcxproj @@ -98,7 +98,7 @@ Level4 true - _CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + LIBCMO_BUILD_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true $(ZLIB_PATH);$(STB_PATH);%(AdditionalIncludeDirectories) stdcpp20 @@ -117,7 +117,7 @@ true true true - _CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + LIBCMO_BUILD_RELEASE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true $(ZLIB_PATH);$(STB_PATH);%(AdditionalIncludeDirectories) stdcpp20 @@ -136,7 +136,7 @@ Level4 true - _CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + LIBCMO_BUILD_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true $(ZLIB_PATH);$(STB_PATH);%(AdditionalIncludeDirectories) stdcpp20 @@ -157,7 +157,7 @@ true true true - _CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + LIBCMO_BUILD_RELEASE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true $(ZLIB_PATH);$(STB_PATH);%(AdditionalIncludeDirectories) stdcpp20 diff --git a/LibCmo/VTUtils.hpp b/LibCmo/VTUtils.hpp index 211c258..7297c78 100644 --- a/LibCmo/VTUtils.hpp +++ b/LibCmo/VTUtils.hpp @@ -1,6 +1,9 @@ #pragma once -/* +#if !defined(LIBCMO_BUILD_DEBUG) && !defined(LIBCMO_BUILD_RELEASE) +#error "You must define LIBCMO_BUILD_DEBUG or LIBCMO_BUILD_RELEASE to indicate build type!" +#endif + // https://stackoverflow.com/questions/2164827/explicitly-exporting-shared-library-functions-in-linux // generate import export macro #if defined(_MSC_VER) @@ -35,7 +38,7 @@ #else #define LIBCMO_EXPORT LIBCMO_NAKED_EXPORT #endif -*/ + #if defined(_WIN32) #define LIBCMO_OS_WIN32 diff --git a/Unvirt/StructFormatter.cpp b/Unvirt/StructFormatter.cpp index a6ccf97..49017a3 100644 --- a/Unvirt/StructFormatter.cpp +++ b/Unvirt/StructFormatter.cpp @@ -63,7 +63,14 @@ namespace Unvirt::StructFormatter { static void PrintCKObjectDetail(LibCmo::CK2::ObjImpls::CKObject* obj) { fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKObject\n")), stdout); - fputs(UNVIRT_TERMCOL_LIGHT_RED(("No Data\n")), stdout); + // print name + fputs("Name: ", stdout); + PrintCKSTRING(obj->GetName()); + fputc('\n', stdout); + // print id + fprintf(stdout, "CK ID: %" PRIuCKID "\n", obj->GetID()); + // print class id + fprintf(stdout, "Class ID: %" PRIiCLASSID " (%s)\n", obj->GetClassID(), AccessibleValue::GetClassIdHierarchy(obj->GetClassID()).c_str()); } static void PrintCKSceneObjectDetail(LibCmo::CK2::ObjImpls::CKSceneObject* obj) { @@ -81,7 +88,21 @@ namespace Unvirt::StructFormatter { static void PrintCKGroupDetail(LibCmo::CK2::ObjImpls::CKGroup* obj) { PrintCKBeObjectDetail(obj); fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKGroup\n")), stdout); - fputs(UNVIRT_TERMCOL_LIGHT_RED(("No Data\n")), stdout); + + LibCmo::CKDWORD count = obj->GetObjectCount(); + fprintf(stdout, "Group Object Count: %" PRIuCKDWORD "\n", count); + fputs("Id\tType\tObject Pointer\tName\n", stdout); + for (LibCmo::CKDWORD i = 0; i < count; ++i) { + LibCmo::CK2::ObjImpls::CKBeObject* beobj = obj->GetObject(i); + + fprintf(stdout, "%" PRIuCKID "\t", beobj->GetID()); + fputs(AccessibleValue::GetClassIdName(beobj->GetClassID()).c_str(), stdout); + fputc('\t', stdout); + PrintPointer(beobj); + fputc('\t', stdout); + PrintCKSTRING(beobj->GetName()); + fputc('\n', stdout); + } } static void PrintCKRenderObjectDetail(LibCmo::CK2::ObjImpls::CKRenderObject* obj) { @@ -119,36 +140,28 @@ namespace Unvirt::StructFormatter { fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKMesh\n")), stdout); fprintf(stdout, "Vertex Count: %" PRIuCKDWORD "\n", obj->GetVertexCount()); - fputs("Type\tAddress\tSize\n", stdout); + fputs("Address\tSize\tType\n", stdout); - fputs("Positions\t", stdout); PrintPointer(obj->GetVertexPositions()); - fprintf(stdout, "\t0x%" PRIxCKDWORD " bytes\n", obj->GetVertexCount() * CKSizeof(LibCmo::VxMath::VxVector3)); - fputs("Normals\t", stdout); + fprintf(stdout, "\t0x%" PRIxCKDWORD " bytes\tPositions\n", obj->GetVertexCount() * CKSizeof(LibCmo::VxMath::VxVector3)); PrintPointer(obj->GetVertexNormals()); - fprintf(stdout, "\t0x%" PRIxCKDWORD " bytes\n", obj->GetVertexCount() * CKSizeof(LibCmo::VxMath::VxVector3)); - fputs("UVs\t", stdout); + fprintf(stdout, "\t0x%" PRIxCKDWORD " bytes\tNormals\n", obj->GetVertexCount() * CKSizeof(LibCmo::VxMath::VxVector3)); PrintPointer(obj->GetVertexUVs()); - fprintf(stdout, "\t0x%" PRIxCKDWORD " bytes\n", obj->GetVertexCount() * CKSizeof(LibCmo::VxMath::VxVector2)); - fputs("Colors\t", stdout); + fprintf(stdout, "\t0x%" PRIxCKDWORD " bytes\tUVs\n", obj->GetVertexCount() * CKSizeof(LibCmo::VxMath::VxVector2)); PrintPointer(obj->GetVertexColors()); - fprintf(stdout, "\t0x%" PRIxCKDWORD " bytes\n", obj->GetVertexCount() * CKSizeof(LibCmo::CKDWORD)); - fputs("SpecularColors\t", stdout); + fprintf(stdout, "\t0x%" PRIxCKDWORD " bytes\tColors\n", obj->GetVertexCount() * CKSizeof(LibCmo::CKDWORD)); PrintPointer(obj->GetVertexSpecularColors()); - fprintf(stdout, "\t0x%" PRIxCKDWORD " bytes\n", obj->GetVertexCount() * CKSizeof(LibCmo::CKDWORD)); - fputs("Weights\t", stdout); + fprintf(stdout, "\t0x%" PRIxCKDWORD " bytes\tSpecularColors\n", obj->GetVertexCount() * CKSizeof(LibCmo::CKDWORD)); PrintPointer(obj->GetVertexWeights()); - fprintf(stdout, "\t0x%" PRIxCKDWORD " bytes\n", obj->GetVertexCount() * CKSizeof(LibCmo::CKFLOAT)); + fprintf(stdout, "\t0x%" PRIxCKDWORD " bytes\tWeights\n", obj->GetVertexCount() * CKSizeof(LibCmo::CKFLOAT)); fprintf(stdout, "Face Count: %" PRIuCKDWORD "\n", obj->GetFaceCount()); - fputs("Type\tAddress\tSize\n", stdout); + fputs("Address\tSize\tType\n", stdout); - fputs("Indices\t", stdout); PrintPointer(obj->GetFaceIndices()); - fprintf(stdout, "\t0x%" PRIxCKDWORD " bytes\n", obj->GetFaceCount() * 3 * CKSizeof(LibCmo::CKWORD)); - fputs("MaterialSlotIndexs\t", stdout); + fprintf(stdout, "\t0x%" PRIxCKDWORD " bytes\tIndices\n", obj->GetFaceCount() * 3 * CKSizeof(LibCmo::CKWORD)); PrintPointer(obj->GetFaceMaterialSlotIndexs()); - fprintf(stdout, "\t0x%" PRIxCKDWORD " bytes\n", obj->GetFaceCount() * CKSizeof(LibCmo::CKWORD)); + fprintf(stdout, "\t0x%" PRIxCKDWORD " bytes\tMaterialSlotIndexs\n", obj->GetFaceCount() * CKSizeof(LibCmo::CKWORD)); } diff --git a/Unvirt/Unvirt.vcxproj b/Unvirt/Unvirt.vcxproj index 70939e8..2dc91e6 100644 --- a/Unvirt/Unvirt.vcxproj +++ b/Unvirt/Unvirt.vcxproj @@ -98,7 +98,7 @@ Level4 true - _CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + LIBCMO_BUILD_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true $(ZLIB_PATH);../LibCmo;$(STB_PATH);%(AdditionalIncludeDirectories) stdcpp20 @@ -118,7 +118,7 @@ true true true - _CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + LIBCMO_BUILD_RELEASE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true $(ZLIB_PATH);../LibCmo;$(STB_PATH);%(AdditionalIncludeDirectories) stdcpp20 @@ -138,7 +138,7 @@ Level4 true - _CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + LIBCMO_BUILD_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true $(ZLIB_PATH);../LibCmo;$(STB_PATH);%(AdditionalIncludeDirectories) stdcpp20 @@ -158,7 +158,7 @@ true true true - _CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + LIBCMO_BUILD_RELEASE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true $(ZLIB_PATH);../LibCmo;$(STB_PATH);%(AdditionalIncludeDirectories) stdcpp20 diff --git a/Unvirt/UnvirtContext.cpp b/Unvirt/UnvirtContext.cpp index 1527759..627cf7a 100644 --- a/Unvirt/UnvirtContext.cpp +++ b/Unvirt/UnvirtContext.cpp @@ -128,6 +128,12 @@ namespace Unvirt::Context { ) ) ) + ->Then((new CmdHelper::Literal("test")) + ->Executes( + std::bind(&UnvirtContext::ProcTest, this, std::placeholders::_1), + "Call custom debugging function (only available in Debug mode)." + ) + ) ->Then((new CmdHelper::Literal("help")) ->Executes( std::bind(&UnvirtContext::ProcHelp, this, std::placeholders::_1), @@ -433,6 +439,16 @@ namespace Unvirt::Context { } } + void Unvirt::Context::UnvirtContext::ProcTest(const CmdHelper::ArgumentsMap* amap) { +#if defined(LIBCMO_BUILD_DEBUG) + // MARK: Add the debug code here. + + +#else + PrintCommonError("Test command only available in Debug mode."); +#endif + } + void Unvirt::Context::UnvirtContext::ProcHelp(const CmdHelper::ArgumentsMap*) { m_Help->Print(); } diff --git a/Unvirt/UnvirtContext.hpp b/Unvirt/UnvirtContext.hpp index e9f578b..ed05126 100644 --- a/Unvirt/UnvirtContext.hpp +++ b/Unvirt/UnvirtContext.hpp @@ -38,6 +38,7 @@ namespace Unvirt::Context { void ProcEncoding(const CmdHelper::ArgumentsMap* amap); void ProcTemp(const CmdHelper::ArgumentsMap* amap); void ProcRsc(const CmdHelper::ArgumentsMap* amap, bool isClear); + void ProcTest(const CmdHelper::ArgumentsMap* amap); void ProcHelp(const CmdHelper::ArgumentsMap* amap); void ProcExit(const CmdHelper::ArgumentsMap* amap);