update shit

This commit is contained in:
yyc12345 2023-02-08 22:57:31 +08:00
parent 9f5f27353f
commit b8da0a802e
27 changed files with 1018 additions and 87 deletions

3
.gitignore vendored
View File

@ -3,6 +3,9 @@
*.cmo
*.nms
*.vmo
CodeGen/dest/*.txt
.vscode/
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

34
CodeGen/CKERROR.py Normal file
View File

@ -0,0 +1,34 @@
full_error = []
annotation = ''
with open('src/CKERROR.txt', 'r', encoding='utf-8') as fr:
while True:
ln = fr.readline()
if ln == '':
break
ln.strip()
if ln == '':
continue
if ln.startswith('#define'):
sp = ln[len('#define'):].strip().split(' ')
# name, value, description
full_error.append((sp[0], sp[-1], annotation))
annotation = ''
elif ln.startswith('//'):
annotation = ln[len('//'):].strip()
fr.close()
with open('dest/CKERROR.txt', 'w', encoding='utf-8') as fw:
for item in full_error:
fw.write('{{ LibCmo::CKERROR::{}, {{"{}", "{}"}} }},\n'.format(
item[0],
item[0],
item[-1])
)
fw.write('\n')
for item in full_error:
fw.write(f'{item[0]} = {item[1]},\n')
fw.close()

86
CodeGen/CKMISC.py Normal file
View File

@ -0,0 +1,86 @@
def RemoveAnnotation(strl: str) -> str:
idx = strl.find("//")
if idx == -1: return strl.strip()
return strl[:idx].strip()
def Underline2Camel(orig: str) -> str:
return ''.join(map(
lambda mixed: mixed[-1].upper() if mixed[0] == '_' else mixed[-1].lower(),
((('_' if idx == 0 else orig[idx - 1]), c) for idx, c in enumerate(orig))
)).replace('_', '')
class EnumEntry():
def __init__(self, name: str, val: str):
self.name: str = name
self.val: str = val
def __repr__(self) -> str:
return f'<{self.name}: {self.val}>'
class EnumBody():
def __init__(self, name: str, is_flag: bool):
self.name: str = name
self.is_flag: bool = is_flag
self.entries: list[EnumEntry] = []
def __repr__(self) -> str:
return self.entries.__repr__()
full_enum: list[EnumBody] = []
current_body: EnumEntry = None
with open('src/CKMISC.txt', 'r', encoding='utf-8') as fr:
while True:
ln = fr.readline()
if ln == '':
break
ln = RemoveAnnotation(ln)
if ln == '':
continue
if ln.startswith('enum'):
ln = ln[len('enum'):].strip()
is_flag = ln[0] == '!'
name = ln[1:] if is_flag else ln
if current_body:
full_enum.append(current_body)
current_body = EnumBody(name, is_flag)
else:
sp = ln.replace(',', '').split('=')
if len(sp) == 1:
entry = EnumEntry(sp[0].strip(), '')
else:
entry = EnumEntry(sp[0].strip(), sp[-1].strip())
current_body.entries.append(entry)
fr.close()
if current_body:
full_enum.append(current_body)
with open('dest/CKMISC.txt', 'w', encoding='utf-8') as fw:
# write define
for item in full_enum:
fw.write('enum class {} : int32_t {{\n'.format(item.name))
fw.write(',\n'.join(map(
lambda x: x.name if x.val == '' else (x.name + ' = ' + x.val),
item.entries
)))
fw.write('\n};\n')
fw.write('\n')
# write vector
for item in full_enum:
fw.write('static const std::array<std::pair<LibCmo::{}, const char*>, {}> _{} {{\n'.format(
item.name, len(item.entries), Underline2Camel(item.name)
))
fw.write(',\n'.join(map(
lambda x: '{{ LibCmo::{}, "{}" }}'.format(x.name, x.name),
item.entries
)))
fw.write('\n};\n')
fw.close()

76
CodeGen/CK_CLASSID.py Normal file
View File

@ -0,0 +1,76 @@
class CKClass():
def __init__(self, name: str, value: int):
self.name: str = name
self.value: int = value
self.parents: tuple[str] = None
def GetLevel(strl: str):
counter = 0
for c in strl:
if c == '\t':
counter += 1
else:
break
return counter
def BuildClass(strl: str) -> CKClass:
strl = strl.replace('#define', '\t').replace(' ', '\t').strip()
sp = strl.split('\t')
return CKClass(sp[0], sp[-1])
def GetParents(ls: list[CKClass]) -> tuple[str]:
return tuple(
map(lambda x: x.name, ls)
)
full_classes = []
with open('src/CK_CLASSID.txt', 'r', encoding='utf-8') as fr:
level = 0
node_stack: list[CKClass] = [None]
while True:
ln = fr.readline()
if ln == '':
break
if ln.strip() == '':
continue
ln = ln.strip('\n')
new_item = BuildClass(ln)
full_classes.append(new_item)
this_level = GetLevel(ln)
if this_level > level:
# level up
level += 1
node_stack.append(new_item)
new_item.parents = GetParents(node_stack)
elif this_level == level:
node_stack.pop()
node_stack.append(new_item)
new_item.parents = GetParents(node_stack)
elif this_level < level:
for i in range(level - this_level + 1):
node_stack.pop()
level = this_level
node_stack.append(new_item)
new_item.parents = GetParents(node_stack)
fr.close()
with open('dest/CK_CLASSID.txt', 'w', encoding='utf-8') as fw:
for item in full_classes:
fw.write('{{ LibCmo::CK_CLASSID::{}, {{{}}} }},\n'.format(
item.parents[-1],
', '.join(
map(lambda x: '"' + x + '"', item.parents)
)
))
fw.write('\n')
for item in full_classes:
fw.write(f'{item.name} = {item.value},\n')
fw.close()

0
CodeGen/dest/.gitkeep Normal file
View File

205
CodeGen/src/CKERROR.txt Normal file
View File

@ -0,0 +1,205 @@
// Operation successful
#define CKERR_OK 0
// One of the parameter passed to the function was invalid
#define CKERR_INVALIDPARAMETER -1
// One of the parameter passed to the function was invalid
#define CKERR_INVALIDPARAMETERTYPE -2
// The parameter size was invalid
#define CKERR_INVALIDSIZE -3
// The operation type didn't exist
#define CKERR_INVALIDOPERATION -4
// The function used to execute the operation is not yet implemented
#define CKERR_OPERATIONNOTIMPLEMENTED -5
// There was not enough memory to perform the action
#define CKERR_OUTOFMEMORY -6
// The function is not yet implemented
#define CKERR_NOTIMPLEMENTED -7
// There was an attempt to remove something not present
#define CKERR_NOTFOUND -11
// There is no level currently created
#define CKERR_NOLEVEL -13
//
#define CKERR_CANCREATERENDERCONTEXT -14
// The notification message was not used
#define CKERR_NOTIFICATIONNOTHANDLED -16
// Attempt to add an item that was already present
#define CKERR_ALREADYPRESENT -17
// the render context is not valid
#define CKERR_INVALIDRENDERCONTEXT -18
// the render context is not activated for rendering
#define CKERR_RENDERCONTEXTINACTIVE -19
// there was no plugins to load this kind of file
#define CKERR_NOLOADPLUGINS -20
// there was no plugins to save this kind of file
#define CKERR_NOSAVEPLUGINS -21
// attempt to load an invalid file
#define CKERR_INVALIDFILE -22
// attempt to load with an invalid plugin
#define CKERR_INVALIDPLUGIN -23
// attempt use an object that wasnt initialized
#define CKERR_NOTINITIALIZED -24
// attempt use a message type that wasn't registred
#define CKERR_INVALIDMESSAGE -25
// attempt use an invalid prototype
#define CKERR_INVALIDPROTOTYPE -28
// No dll file found in the parse directory
#define CKERR_NODLLFOUND -29
// this dll has already been registred
#define CKERR_ALREADYREGISTREDDLL -30
// this dll does not contain information to create the prototype
#define CKERR_INVALIDDLL -31
// Invalid Object (attempt to Get an object from an invalid ID)
#define CKERR_INVALIDOBJECT -34
// Invalid window was provided as console window
#define CKERR_INVALIDCONDSOLEWINDOW -35
// Invalid kinematic chain ( end and start effector may not be part of the same hierarchy )
#define CKERR_INVALIDKINEMATICCHAIN -36
// Keyboard not attached or not working properly
#define CKERR_NOKEYBOARD -37
// Mouse not attached or not working properly
#define CKERR_NOMOUSE -38
// Joystick not attached or not working properly
#define CKERR_NOJOYSTICK -39
// Try to link imcompatible Parameters
#define CKERR_INCOMPATIBLEPARAMETERS -40
// There is no render engine dll
#define CKERR_NORENDERENGINE -44
// There is no current level (use CKSetCurrentLevel )
#define CKERR_NOCURRENTLEVEL -45
// Sound Management has been disabled
#define CKERR_SOUNDDISABLED -46
// DirectInput Management has been disabled
#define CKERR_DINPUTDISABLED -47
// Guid is already in use or invalid
#define CKERR_INVALIDGUID -48
// There was no more free space on disk when trying to save a file
#define CKERR_NOTENOUGHDISKPLACE -49
// Impossible to write to file (write-protection ?)
#define CKERR_CANTWRITETOFILE -50
// The behavior cannnot be added to this entity
#define CKERR_BEHAVIORADDDENIEDBYCB -51
// The behavior cannnot be added to this entity
#define CKERR_INCOMPATIBLECLASSID -52
// A manager was registered more than once
#define CKERR_MANAGERALREADYEXISTS -53
// CKprocess or TimeManager process while CK is paused will fail
#define CKERR_PAUSED -54
// Some plugins were missing whileloading a file
#define CKERR_PLUGINSMISSING -55
// Virtools version too old to load this file
#define CKERR_OBSOLETEVIRTOOLS -56
// CRC Error while loading file
#define CKERR_FILECRCERROR -57
// A Render context is already in Fullscreen Mode
#define CKERR_ALREADYFULLSCREEN -58
// Operation was cancelled by user
#define CKERR_CANCELLED -59
// there were no animation key at the given index
#define CKERR_NOANIMATIONKEY -121
// attemp to acces an animation key with an invalid index
#define CKERR_INVALIDINDEX -122
// the animation is invalid (no entity associated or zero length)
#define CKERR_INVALIDANIMATION -123

27
CodeGen/src/CKMISC.txt Normal file
View File

@ -0,0 +1,27 @@
enum !CK_FILE_WRITEMODE
CKFILE_UNCOMPRESSED =0, // Save data uncompressed
CKFILE_CHUNKCOMPRESSED_OLD =1, // Obsolete
CKFILE_EXTERNALTEXTURES_OLD=2, // Obsolete : use CKContext::SetGlobalImagesSaveOptions instead.
CKFILE_FORVIEWER =4, // Don't save Interface Data within the file, the level won't be editable anymore in the interface
CKFILE_WHOLECOMPRESSED =8, // Compress the whole file
enum !CK_LOAD_FLAGS
CK_LOAD_ANIMATION =1<<0, // Load animations
CK_LOAD_GEOMETRY =1<<1, // Load geometry.
CK_LOAD_DEFAULT =CK_LOAD_GEOMETRY|CK_LOAD_ANIMATION, // Load animations & geometry
CK_LOAD_ASCHARACTER =1<<2, // Load all the objects and create a character that contains them all .
CK_LOAD_DODIALOG =1<<3, // Check object name unicity and warns the user with a dialog box when duplicate names are found.
CK_LOAD_AS_DYNAMIC_OBJECT =1<<4, // Objects loaded from this file may be deleted at run-time or are temporary
CK_LOAD_AUTOMATICMODE =1<<5, // Check object name unicity and automatically rename or replace according to the options specified in CKContext::SetAutomaticLoadMode
CK_LOAD_CHECKDUPLICATES =1<<6, // Check object name unicity (The list of duplicates is stored in the CKFile class after a OpenFile call
CK_LOAD_CHECKDEPENDENCIES =1<<7, // Check if every plugins needed are availables
CK_LOAD_ONLYBEHAVIORS =1<<8, //
enum CK_FO_OPTIONS
CK_FO_DEFAULT = 0, // Default behavior : a new object will be created with the name stored in CKFileObject
CK_FO_RENAMEOBJECT, // Renaming : a new object will be created with the name stored in CKFileObject + a integer value XXX to ensure its uniqueness
CK_FO_REPLACEOBJECT, // Do not create a new object, instead use an existing one which CK_ID is given by CreatedObject
// to load the chunk on
CK_FO_DONTLOADOBJECT, // Object chunk will not be read either because it is a reference
// or because the loaded object already exist in the current level
// and the user choose to keep the existing one.

View File

@ -0,0 +1,70 @@
#define CKCID_OBJECT 1
#define CKCID_PARAMETERIN 2
#define CKCID_PARAMETEROPERATION 4
#define CKCID_STATE 5
#define CKCID_BEHAVIORLINK 6
#define CKCID_BEHAVIOR 8
#define CKCID_BEHAVIORIO 9
#define CKCID_RENDERCONTEXT 12
#define CKCID_KINEMATICCHAIN 13
#define CKCID_SCENEOBJECT 11
#define CKCID_OBJECTANIMATION 15
#define CKCID_ANIMATION 16
#define CKCID_KEYEDANIMATION 18
#define CKCID_BEOBJECT 19
#define CKCID_DATAARRAY 52
#define CKCID_SCENE 10
#define CKCID_LEVEL 21
#define CKCID_PLACE 22
#define CKCID_GROUP 23
#define CKCID_SOUND 24
#define CKCID_WAVESOUND 25
#define CKCID_MIDISOUND 26
#define CKCID_MATERIAL 30
#define CKCID_TEXTURE 31
#define CKCID_MESH 32
#define CKCID_PATCHMESH 53
#define CKCID_RENDEROBJECT 47
#define CKCID_2DENTITY 27
#define CKCID_SPRITE 28
#define CKCID_SPRITETEXT 29
#define CKCID_3DENTITY 33
#define CKCID_GRID 50
#define CKCID_CURVEPOINT 36
#define CKCID_SPRITE3D 37
#define CKCID_CURVE 43
#define CKCID_CAMERA 34
#define CKCID_TARGETCAMERA 35
#define CKCID_LIGHT 38
#define CKCID_TARGETLIGHT 39
#define CKCID_CHARACTER 40
#define CKCID_3DOBJECT 41
#define CKCID_BODYPART 42
#define CKCID_PARAMETER 46
#define CKCID_PARAMETERLOCAL 45
#define CKCID_PARAMETERVARIABLE 55
#define CKCID_PARAMETEROUT 3
#define CKCID_INTERFACEOBJECTMANAGER 48
#define CKCID_CRITICALSECTION 49
#define CKCID_LAYER 51
#define CKCID_PROGRESSIVEMESH 54
#define CKCID_SYNCHRO 20
#define CKCID_OBJECTARRAY 80
#define CKCID_SCENEOBJECTDESC 81
#define CKCID_ATTRIBUTEMANAGER 82
#define CKCID_MESSAGEMANAGER 83
#define CKCID_COLLISIONMANAGER 84
#define CKCID_OBJECTMANAGER 85
#define CKCID_FLOORMANAGER 86
#define CKCID_RENDERMANAGER 87
#define CKCID_BEHAVIORMANAGER 88
#define CKCID_INPUTMANAGER 89
#define CKCID_PARAMETERMANAGER 90
#define CKCID_GRIDMANAGER 91
#define CKCID_SOUNDMANAGER 92
#define CKCID_TIMEMANAGER 93
#define CKCID_CUIKBEHDATA -1
#define CKCID_MAXCLASSID 56
#define CKCID_MAXMAXCLASSID 128

View File

@ -100,14 +100,14 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>LIBCMO_EXPORTING;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<CompileAs>CompileAsC</CompileAs>
<AdditionalIncludeDirectories>$(ZLIB_PATH);$(GLIB_EXTRA_INCLUDE_PATH);$(GLIB_INCLUDE_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(BOOST_MMAP_INCLUDE_PATH);$(ZLIB_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ZLIB_PATH)\contrib\vstudio\vc14\x86\ZlibDllReleaseWithoutAsm;$(GLIB_WIN32_LIB_PATH);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>glib-2.0.lib;zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ZLIB_PATH)\contrib\vstudio\vc14\x86\ZlibDllReleaseWithoutAsm;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -118,16 +118,16 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>LIBCMO_EXPORTING;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<CompileAs>CompileAsC</CompileAs>
<AdditionalIncludeDirectories>$(ZLIB_PATH);$(GLIB_EXTRA_INCLUDE_PATH);$(GLIB_INCLUDE_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(BOOST_MMAP_INCLUDE_PATH);$(ZLIB_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ZLIB_PATH)\contrib\vstudio\vc14\x86\ZlibDllReleaseWithoutAsm;$(GLIB_WIN32_LIB_PATH);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>glib-2.0.lib;zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ZLIB_PATH)\contrib\vstudio\vc14\x86\ZlibDllReleaseWithoutAsm;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -136,14 +136,14 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>LIBCMO_EXPORTING;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<CompileAs>CompileAsC</CompileAs>
<AdditionalIncludeDirectories>$(ZLIB_PATH);$(GLIB_EXTRA_INCLUDE_PATH);$(GLIB_INCLUDE_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(BOOST_MMAP_INCLUDE_PATH);$(ZLIB_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ZLIB_PATH)\contrib\vstudio\vc14\x64\ZlibDllReleaseWithoutAsm;$(GLIB_WIN64_LIB_PATH)</AdditionalLibraryDirectories>
<AdditionalDependencies>glib-2.0.lib;zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ZLIB_PATH)\contrib\vstudio\vc14\x64\ZlibDllReleaseWithoutAsm</AdditionalLibraryDirectories>
<AdditionalDependencies>zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -154,26 +154,26 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>LIBCMO_EXPORTING;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<CompileAs>CompileAsC</CompileAs>
<AdditionalIncludeDirectories>$(ZLIB_PATH);$(GLIB_EXTRA_INCLUDE_PATH);$(GLIB_INCLUDE_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(BOOST_MMAP_INCLUDE_PATH);$(ZLIB_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ZLIB_PATH)\contrib\vstudio\vc14\x64\ZlibDllReleaseWithoutAsm;$(GLIB_WIN64_LIB_PATH)</AdditionalLibraryDirectories>
<AdditionalDependencies>glib-2.0.lib;zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ZLIB_PATH)\contrib\vstudio\vc14\x64\ZlibDllReleaseWithoutAsm</AdditionalLibraryDirectories>
<AdditionalDependencies>zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="VTReader.c" />
<ClCompile Include="VTReader.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="VTConstants.h" />
<ClInclude Include="VTReader.h" />
<ClInclude Include="VTStruct.h" />
<ClInclude Include="VTUtils.h" />
<ClInclude Include="VTConstants.hpp" />
<ClInclude Include="VTReader.hpp" />
<ClInclude Include="VTStruct.hpp" />
<ClInclude Include="VTUtils.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -15,21 +15,21 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="VTReader.c">
<ClCompile Include="VTReader.cpp">
<Filter>Sources</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="VTReader.h">
<ClInclude Include="VTReader.hpp">
<Filter>Headers</Filter>
</ClInclude>
<ClInclude Include="VTStruct.h">
<ClInclude Include="VTStruct.hpp">
<Filter>Headers</Filter>
</ClInclude>
<ClInclude Include="VTConstants.h">
<ClInclude Include="VTConstants.hpp">
<Filter>Headers</Filter>
</ClInclude>
<ClInclude Include="VTUtils.h">
<ClInclude Include="VTUtils.hpp">
<Filter>Headers</Filter>
</ClInclude>
</ItemGroup>

View File

@ -1,6 +0,0 @@
#pragma once
#include <inttypes.h>
#include <stdint.h>
#define CKERROR int32_t

138
LibCmo/VTConstants.hpp Normal file
View File

@ -0,0 +1,138 @@
#pragma once
#include <cinttypes>
#include <cstdint>
namespace LibCmo {
using CK_ID = uint32_t;
enum class CK_CLASSID : uint32_t {
CKCID_OBJECT = 1,
CKCID_PARAMETERIN = 2,
CKCID_PARAMETEROPERATION = 4,
CKCID_STATE = 5,
CKCID_BEHAVIORLINK = 6,
CKCID_BEHAVIOR = 8,
CKCID_BEHAVIORIO = 9,
CKCID_RENDERCONTEXT = 12,
CKCID_KINEMATICCHAIN = 13,
CKCID_SCENEOBJECT = 11,
CKCID_OBJECTANIMATION = 15,
CKCID_ANIMATION = 16,
CKCID_KEYEDANIMATION = 18,
CKCID_BEOBJECT = 19,
CKCID_DATAARRAY = 52,
CKCID_SCENE = 10,
CKCID_LEVEL = 21,
CKCID_PLACE = 22,
CKCID_GROUP = 23,
CKCID_SOUND = 24,
CKCID_WAVESOUND = 25,
CKCID_MIDISOUND = 26,
CKCID_MATERIAL = 30,
CKCID_TEXTURE = 31,
CKCID_MESH = 32,
CKCID_PATCHMESH = 53,
CKCID_RENDEROBJECT = 47,
CKCID_2DENTITY = 27,
CKCID_SPRITE = 28,
CKCID_SPRITETEXT = 29,
CKCID_3DENTITY = 33,
CKCID_GRID = 50,
CKCID_CURVEPOINT = 36,
CKCID_SPRITE3D = 37,
CKCID_CURVE = 43,
CKCID_CAMERA = 34,
CKCID_TARGETCAMERA = 35,
CKCID_LIGHT = 38,
CKCID_TARGETLIGHT = 39,
CKCID_CHARACTER = 40,
CKCID_3DOBJECT = 41,
CKCID_BODYPART = 42,
CKCID_PARAMETER = 46,
CKCID_PARAMETERLOCAL = 45,
CKCID_PARAMETERVARIABLE = 55,
CKCID_PARAMETEROUT = 3,
CKCID_INTERFACEOBJECTMANAGER = 48,
CKCID_CRITICALSECTION = 49,
CKCID_LAYER = 51,
CKCID_PROGRESSIVEMESH = 54,
CKCID_SYNCHRO = 20,
CKCID_OBJECTARRAY = 80,
CKCID_SCENEOBJECTDESC = 81,
CKCID_ATTRIBUTEMANAGER = 82,
CKCID_MESSAGEMANAGER = 83,
CKCID_COLLISIONMANAGER = 84,
CKCID_OBJECTMANAGER = 85,
CKCID_FLOORMANAGER = 86,
CKCID_RENDERMANAGER = 87,
CKCID_BEHAVIORMANAGER = 88,
CKCID_INPUTMANAGER = 89,
CKCID_PARAMETERMANAGER = 90,
CKCID_GRIDMANAGER = 91,
CKCID_SOUNDMANAGER = 92,
CKCID_TIMEMANAGER = 93,
CKCID_CUIKBEHDATA = (uint32_t)-1,
CKCID_MAXCLASSID = 56,
CKCID_MAXMAXCLASSID = 128
};
enum class CKERROR : int32_t {
CKERR_OK = 0,
CKERR_INVALIDPARAMETER = -1,
CKERR_INVALIDPARAMETERTYPE = -2,
CKERR_INVALIDSIZE = -3,
CKERR_INVALIDOPERATION = -4,
CKERR_OPERATIONNOTIMPLEMENTED = -5,
CKERR_OUTOFMEMORY = -6,
CKERR_NOTIMPLEMENTED = -7,
CKERR_NOTFOUND = -11,
CKERR_NOLEVEL = -13,
CKERR_CANCREATERENDERCONTEXT = -14,
CKERR_NOTIFICATIONNOTHANDLED = -16,
CKERR_ALREADYPRESENT = -17,
CKERR_INVALIDRENDERCONTEXT = -18,
CKERR_RENDERCONTEXTINACTIVE = -19,
CKERR_NOLOADPLUGINS = -20,
CKERR_NOSAVEPLUGINS = -21,
CKERR_INVALIDFILE = -22,
CKERR_INVALIDPLUGIN = -23,
CKERR_NOTINITIALIZED = -24,
CKERR_INVALIDMESSAGE = -25,
CKERR_INVALIDPROTOTYPE = -28,
CKERR_NODLLFOUND = -29,
CKERR_ALREADYREGISTREDDLL = -30,
CKERR_INVALIDDLL = -31,
CKERR_INVALIDOBJECT = -34,
CKERR_INVALIDCONDSOLEWINDOW = -35,
CKERR_INVALIDKINEMATICCHAIN = -36,
CKERR_NOKEYBOARD = -37,
CKERR_NOMOUSE = -38,
CKERR_NOJOYSTICK = -39,
CKERR_INCOMPATIBLEPARAMETERS = -40,
CKERR_NORENDERENGINE = -44,
CKERR_NOCURRENTLEVEL = -45,
CKERR_SOUNDDISABLED = -46,
CKERR_DINPUTDISABLED = -47,
CKERR_INVALIDGUID = -48,
CKERR_NOTENOUGHDISKPLACE = -49,
CKERR_CANTWRITETOFILE = -50,
CKERR_BEHAVIORADDDENIEDBYCB = -51,
CKERR_INCOMPATIBLECLASSID = -52,
CKERR_MANAGERALREADYEXISTS = -53,
CKERR_PAUSED = -54,
CKERR_PLUGINSMISSING = -55,
CKERR_OBSOLETEVIRTOOLS = -56,
CKERR_FILECRCERROR = -57,
CKERR_ALREADYFULLSCREEN = -58,
CKERR_CANCELLED = -59,
CKERR_NOANIMATIONKEY = -121,
CKERR_INVALIDINDEX = -122,
CKERR_INVALIDANIMATION = -123
};
}

View File

@ -1,9 +0,0 @@
#include "VTReader.h"
CKERROR ReadFileHeaders(void) {
return 0;
}
CKERROR Load(void) {
return 0;
}

13
LibCmo/VTReader.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "VTReader.hpp"
namespace LibCmo {
CKERROR ReadFileHeaders(void) {
return CKERROR::CKERR_OK;
}
CKERROR Load(void) {
return CKERROR::CKERR_OK;
}
}

View File

@ -1,8 +0,0 @@
#pragma once
#include "VTUtils.h"
#include "VTConstants.h"
LIBCMO_EXPORT CKERROR ReadFileHeaders(void);
LIBCMO_EXPORT CKERROR Load(void);

12
LibCmo/VTReader.hpp Normal file
View File

@ -0,0 +1,12 @@
#pragma once
#include "VTUtils.hpp"
#include "VTConstants.hpp"
namespace LibCmo {
LIBCMO_EXPORT CKERROR ReadFileHeaders(void);
LIBCMO_EXPORT CKERROR Load(void);
}

View File

@ -2,10 +2,7 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros">
<GLIB_INCLUDE_PATH>D:\CppLib\GLib\Win32\include\glib-2.0</GLIB_INCLUDE_PATH>
<GLIB_EXTRA_INCLUDE_PATH>D:\CppLib\GLib\Win32\lib\glib-2.0\include</GLIB_EXTRA_INCLUDE_PATH>
<GLIB_WIN32_LIB_PATH>D:\CppLib\GLib\Win32\lib</GLIB_WIN32_LIB_PATH>
<GLIB_WIN64_LIB_PATH>D:\CppLib\GLib\x64\lib</GLIB_WIN64_LIB_PATH>
<BOOST_MMAP_INCLUDE_PATH>D:\CppLib\interprocess-boost-1.81.0\include</BOOST_MMAP_INCLUDE_PATH>
<SQLITE_HEADER_PATH>D:\CppLib\SQLite\sqlite-amalgamation-3400100</SQLITE_HEADER_PATH>
<SQLITE_WIN32_LIB_PATH>D:\CppLib\SQLite\sqlite-dll-win32-x86-3400100</SQLITE_WIN32_LIB_PATH>
@ -16,17 +13,8 @@
<PropertyGroup />
<ItemDefinitionGroup />
<ItemGroup>
<BuildMacro Include="GLIB_INCLUDE_PATH">
<Value>$(GLIB_INCLUDE_PATH)</Value>
</BuildMacro>
<BuildMacro Include="GLIB_EXTRA_INCLUDE_PATH">
<Value>$(GLIB_EXTRA_INCLUDE_PATH)</Value>
</BuildMacro>
<BuildMacro Include="GLIB_WIN32_LIB_PATH">
<Value>$(GLIB_WIN32_LIB_PATH)</Value>
</BuildMacro>
<BuildMacro Include="GLIB_WIN64_LIB_PATH">
<Value>$(GLIB_WIN64_LIB_PATH)</Value>
<BuildMacro Include="BOOST_MMAP_INCLUDE_PATH">
<Value>$(BOOST_MMAP_INCLUDE_PATH)</Value>
</BuildMacro>
<BuildMacro Include="SQLITE_HEADER_PATH">

221
Unvirt/AccessibleValue.cpp Normal file
View File

@ -0,0 +1,221 @@
#include "AccessibleValue.hpp"
#include "StringHelper.hpp"
#include <vector>
#include <array>
namespace Unvirt {
namespace AccessibleValue {
template<typename TKey, typename TValue>
static inline const TValue* GetEnumData(const std::vector<std::pair<TKey, TValue>>& vec, const TKey key) {
size_t len = vec.size();
for (size_t i = 0; i < len; ++i) {
if (key == vec[i].first) return &vec[i].second;
}
return nullptr;
}
static const std::vector<std::pair<LibCmo::CKERROR, std::array<const char*, 2>>> _CkErrorData{
{ LibCmo::CKERROR::CKERR_OK, { "CKERR_OK", "Operation successful" } },
{ LibCmo::CKERROR::CKERR_INVALIDPARAMETER, {"CKERR_INVALIDPARAMETER", "One of the parameter passed to the function was invalid"} },
{ LibCmo::CKERROR::CKERR_INVALIDPARAMETERTYPE, {"CKERR_INVALIDPARAMETERTYPE", "One of the parameter passed to the function was invalid"} },
{ LibCmo::CKERROR::CKERR_INVALIDSIZE, {"CKERR_INVALIDSIZE", "The parameter size was invalid"} },
{ LibCmo::CKERROR::CKERR_INVALIDOPERATION, {"CKERR_INVALIDOPERATION", "The operation type didn't exist"} },
{ LibCmo::CKERROR::CKERR_OPERATIONNOTIMPLEMENTED, {"CKERR_OPERATIONNOTIMPLEMENTED", "The function used to execute the operation is not yet implemented"} },
{ LibCmo::CKERROR::CKERR_OUTOFMEMORY, {"CKERR_OUTOFMEMORY", "There was not enough memory to perform the action"} },
{ LibCmo::CKERROR::CKERR_NOTIMPLEMENTED, {"CKERR_NOTIMPLEMENTED", "The function is not yet implemented"} },
{ LibCmo::CKERROR::CKERR_NOTFOUND, {"CKERR_NOTFOUND", "There was an attempt to remove something not present"} },
{ LibCmo::CKERROR::CKERR_NOLEVEL, {"CKERR_NOLEVEL", "There is no level currently created"} },
{ LibCmo::CKERROR::CKERR_CANCREATERENDERCONTEXT, {"CKERR_CANCREATERENDERCONTEXT", ""} },
{ LibCmo::CKERROR::CKERR_NOTIFICATIONNOTHANDLED, {"CKERR_NOTIFICATIONNOTHANDLED", "The notification message was not used"} },
{ LibCmo::CKERROR::CKERR_ALREADYPRESENT, {"CKERR_ALREADYPRESENT", "Attempt to add an item that was already present"} },
{ LibCmo::CKERROR::CKERR_INVALIDRENDERCONTEXT, {"CKERR_INVALIDRENDERCONTEXT", "the render context is not valid"} },
{ LibCmo::CKERROR::CKERR_RENDERCONTEXTINACTIVE, {"CKERR_RENDERCONTEXTINACTIVE", "the render context is not activated for rendering"} },
{ LibCmo::CKERROR::CKERR_NOLOADPLUGINS, {"CKERR_NOLOADPLUGINS", "there was no plugins to load this kind of file"} },
{ LibCmo::CKERROR::CKERR_NOSAVEPLUGINS, {"CKERR_NOSAVEPLUGINS", "there was no plugins to save this kind of file"} },
{ LibCmo::CKERROR::CKERR_INVALIDFILE, {"CKERR_INVALIDFILE", "attempt to load an invalid file"} },
{ LibCmo::CKERROR::CKERR_INVALIDPLUGIN, {"CKERR_INVALIDPLUGIN", "attempt to load with an invalid plugin"} },
{ LibCmo::CKERROR::CKERR_NOTINITIALIZED, {"CKERR_NOTINITIALIZED", "attempt use an object that wasnt initialized"} },
{ LibCmo::CKERROR::CKERR_INVALIDMESSAGE, {"CKERR_INVALIDMESSAGE", "attempt use a message type that wasn't registred"} },
{ LibCmo::CKERROR::CKERR_INVALIDPROTOTYPE, {"CKERR_INVALIDPROTOTYPE", "attempt use an invalid prototype"} },
{ LibCmo::CKERROR::CKERR_NODLLFOUND, {"CKERR_NODLLFOUND", "No dll file found in the parse directory"} },
{ LibCmo::CKERROR::CKERR_ALREADYREGISTREDDLL, {"CKERR_ALREADYREGISTREDDLL", "this dll has already been registred"} },
{ LibCmo::CKERROR::CKERR_INVALIDDLL, {"CKERR_INVALIDDLL", "this dll does not contain information to create the prototype"} },
{ LibCmo::CKERROR::CKERR_INVALIDOBJECT, {"CKERR_INVALIDOBJECT", "Invalid Object (attempt to Get an object from an invalid ID)"} },
{ LibCmo::CKERROR::CKERR_INVALIDCONDSOLEWINDOW, {"CKERR_INVALIDCONDSOLEWINDOW", "Invalid window was provided as console window"} },
{ LibCmo::CKERROR::CKERR_INVALIDKINEMATICCHAIN, {"CKERR_INVALIDKINEMATICCHAIN", "Invalid kinematic chain ( end and start effector may not be part of the same hierarchy )"} },
{ LibCmo::CKERROR::CKERR_NOKEYBOARD, {"CKERR_NOKEYBOARD", "Keyboard not attached or not working properly"} },
{ LibCmo::CKERROR::CKERR_NOMOUSE, {"CKERR_NOMOUSE", "Mouse not attached or not working properly"} },
{ LibCmo::CKERROR::CKERR_NOJOYSTICK, {"CKERR_NOJOYSTICK", "Joystick not attached or not working properly"} },
{ LibCmo::CKERROR::CKERR_INCOMPATIBLEPARAMETERS, {"CKERR_INCOMPATIBLEPARAMETERS", "Try to link imcompatible Parameters"} },
{ LibCmo::CKERROR::CKERR_NORENDERENGINE, {"CKERR_NORENDERENGINE", "There is no render engine dll"} },
{ LibCmo::CKERROR::CKERR_NOCURRENTLEVEL, {"CKERR_NOCURRENTLEVEL", "There is no current level (use CKSetCurrentLevel )"} },
{ LibCmo::CKERROR::CKERR_SOUNDDISABLED, {"CKERR_SOUNDDISABLED", "Sound Management has been disabled"} },
{ LibCmo::CKERROR::CKERR_DINPUTDISABLED, {"CKERR_DINPUTDISABLED", "DirectInput Management has been disabled"} },
{ LibCmo::CKERROR::CKERR_INVALIDGUID, {"CKERR_INVALIDGUID", "Guid is already in use or invalid"} },
{ LibCmo::CKERROR::CKERR_NOTENOUGHDISKPLACE, {"CKERR_NOTENOUGHDISKPLACE", "There was no more free space on disk when trying to save a file"} },
{ LibCmo::CKERROR::CKERR_CANTWRITETOFILE, {"CKERR_CANTWRITETOFILE", "Impossible to write to file (write-protection ?)"} },
{ LibCmo::CKERROR::CKERR_BEHAVIORADDDENIEDBYCB, {"CKERR_BEHAVIORADDDENIEDBYCB", "The behavior cannnot be added to this entity"} },
{ LibCmo::CKERROR::CKERR_INCOMPATIBLECLASSID, {"CKERR_INCOMPATIBLECLASSID", "The behavior cannnot be added to this entity"} },
{ LibCmo::CKERROR::CKERR_MANAGERALREADYEXISTS, {"CKERR_MANAGERALREADYEXISTS", "A manager was registered more than once"} },
{ LibCmo::CKERROR::CKERR_PAUSED, {"CKERR_PAUSED", "CKprocess or TimeManager process while CK is paused will fail"} },
{ LibCmo::CKERROR::CKERR_PLUGINSMISSING, {"CKERR_PLUGINSMISSING", "Some plugins were missing whileloading a file"} },
{ LibCmo::CKERROR::CKERR_OBSOLETEVIRTOOLS, {"CKERR_OBSOLETEVIRTOOLS", "Virtools version too old to load this file"} },
{ LibCmo::CKERROR::CKERR_FILECRCERROR, {"CKERR_FILECRCERROR", "CRC Error while loading file"} },
{ LibCmo::CKERROR::CKERR_ALREADYFULLSCREEN, {"CKERR_ALREADYFULLSCREEN", "A Render context is already in Fullscreen Mode"} },
{ LibCmo::CKERROR::CKERR_CANCELLED, {"CKERR_CANCELLED", "Operation was cancelled by user"} },
{ LibCmo::CKERROR::CKERR_NOANIMATIONKEY, {"CKERR_NOANIMATIONKEY", "there were no animation key at the given index"} },
{ LibCmo::CKERROR::CKERR_INVALIDINDEX, {"CKERR_INVALIDINDEX", "attemp to acces an animation key with an invalid index"} },
{ LibCmo::CKERROR::CKERR_INVALIDANIMATION, {"CKERR_INVALIDANIMATION", "the animation is invalid (no entity associated or zero length)"} }
};
void GetCkErrorName(std::string& strl, LibCmo::CKERROR err) {
strl.clear();
const std::array<const char*, 2>* pErrDesc = GetEnumData<LibCmo::CKERROR, std::array<const char*, 2>>(
_CkErrorData, err
);
if (pErrDesc != nullptr) {
strl = pErrDesc->front();
}
}
void GetCkErrorDescription(std::string& strl, LibCmo::CKERROR err) {
strl.clear();
const std::array<const char*, 2>* pErrDesc = GetEnumData<LibCmo::CKERROR, std::array<const char*, 2>>(
_CkErrorData, err
);
if (pErrDesc != nullptr) {
strl = pErrDesc->back();
}
}
static const std::vector<std::pair<LibCmo::CK_CLASSID, std::vector<const char*>>> _CkClassHierarchy{
{ LibCmo::CK_CLASSID::CKCID_OBJECT, {"CKCID_OBJECT"} },
{ LibCmo::CK_CLASSID::CKCID_PARAMETERIN, {"CKCID_OBJECT", "CKCID_PARAMETERIN"} },
{ LibCmo::CK_CLASSID::CKCID_PARAMETEROPERATION, {"CKCID_OBJECT", "CKCID_PARAMETEROPERATION"} },
{ LibCmo::CK_CLASSID::CKCID_STATE, {"CKCID_OBJECT", "CKCID_STATE"} },
{ LibCmo::CK_CLASSID::CKCID_BEHAVIORLINK, {"CKCID_OBJECT", "CKCID_BEHAVIORLINK"} },
{ LibCmo::CK_CLASSID::CKCID_BEHAVIOR, {"CKCID_OBJECT", "CKCID_BEHAVIOR"} },
{ LibCmo::CK_CLASSID::CKCID_BEHAVIORIO, {"CKCID_OBJECT", "CKCID_BEHAVIORIO"} },
{ LibCmo::CK_CLASSID::CKCID_RENDERCONTEXT, {"CKCID_OBJECT", "CKCID_RENDERCONTEXT"} },
{ LibCmo::CK_CLASSID::CKCID_KINEMATICCHAIN, {"CKCID_OBJECT", "CKCID_KINEMATICCHAIN"} },
{ LibCmo::CK_CLASSID::CKCID_SCENEOBJECT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT"} },
{ LibCmo::CK_CLASSID::CKCID_OBJECTANIMATION, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_OBJECTANIMATION"} },
{ LibCmo::CK_CLASSID::CKCID_ANIMATION, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_ANIMATION"} },
{ LibCmo::CK_CLASSID::CKCID_KEYEDANIMATION, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_ANIMATION", "CKCID_KEYEDANIMATION"} },
{ LibCmo::CK_CLASSID::CKCID_BEOBJECT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT"} },
{ LibCmo::CK_CLASSID::CKCID_DATAARRAY, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_DATAARRAY"} },
{ LibCmo::CK_CLASSID::CKCID_SCENE, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_SCENE"} },
{ LibCmo::CK_CLASSID::CKCID_LEVEL, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_LEVEL"} },
{ LibCmo::CK_CLASSID::CKCID_PLACE, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_PLACE"} },
{ LibCmo::CK_CLASSID::CKCID_GROUP, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_GROUP"} },
{ LibCmo::CK_CLASSID::CKCID_SOUND, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_SOUND"} },
{ LibCmo::CK_CLASSID::CKCID_WAVESOUND, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_SOUND", "CKCID_WAVESOUND"} },
{ LibCmo::CK_CLASSID::CKCID_MIDISOUND, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_SOUND", "CKCID_MIDISOUND"} },
{ LibCmo::CK_CLASSID::CKCID_MATERIAL, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_MATERIAL"} },
{ LibCmo::CK_CLASSID::CKCID_TEXTURE, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_TEXTURE"} },
{ LibCmo::CK_CLASSID::CKCID_MESH, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_MESH"} },
{ LibCmo::CK_CLASSID::CKCID_PATCHMESH, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_MESH", "CKCID_PATCHMESH"} },
{ LibCmo::CK_CLASSID::CKCID_RENDEROBJECT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_RENDEROBJECT"} },
{ LibCmo::CK_CLASSID::CKCID_2DENTITY, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_RENDEROBJECT", "CKCID_2DENTITY"} },
{ LibCmo::CK_CLASSID::CKCID_SPRITE, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_RENDEROBJECT", "CKCID_2DENTITY", "CKCID_SPRITE"} },
{ LibCmo::CK_CLASSID::CKCID_SPRITETEXT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_RENDEROBJECT", "CKCID_2DENTITY", "CKCID_SPRITETEXT"} },
{ LibCmo::CK_CLASSID::CKCID_3DENTITY, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY"} },
{ LibCmo::CK_CLASSID::CKCID_GRID, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_GRID"} },
{ LibCmo::CK_CLASSID::CKCID_CURVEPOINT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CURVEPOINT"} },
{ LibCmo::CK_CLASSID::CKCID_SPRITE3D, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_SPRITE3D"} },
{ LibCmo::CK_CLASSID::CKCID_CURVE, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CURVE"} },
{ LibCmo::CK_CLASSID::CKCID_CAMERA, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CAMERA"} },
{ LibCmo::CK_CLASSID::CKCID_TARGETCAMERA, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CAMERA", "CKCID_TARGETCAMERA"} },
{ LibCmo::CK_CLASSID::CKCID_LIGHT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_LIGHT"} },
{ LibCmo::CK_CLASSID::CKCID_TARGETLIGHT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_LIGHT", "CKCID_TARGETLIGHT"} },
{ LibCmo::CK_CLASSID::CKCID_CHARACTER, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CHARACTER"} },
{ LibCmo::CK_CLASSID::CKCID_3DOBJECT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_3DOBJECT"} },
{ LibCmo::CK_CLASSID::CKCID_BODYPART, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_3DOBJECT", "CKCID_BODYPART"} },
{ LibCmo::CK_CLASSID::CKCID_PARAMETER, {"CKCID_OBJECT", "CKCID_PARAMETER"} },
{ LibCmo::CK_CLASSID::CKCID_PARAMETERLOCAL, {"CKCID_OBJECT", "CKCID_PARAMETER", "CKCID_PARAMETERLOCAL"} },
{ LibCmo::CK_CLASSID::CKCID_PARAMETERVARIABLE, {"CKCID_OBJECT", "CKCID_PARAMETER", "CKCID_PARAMETERLOCAL", "CKCID_PARAMETERVARIABLE"} },
{ LibCmo::CK_CLASSID::CKCID_PARAMETEROUT, {"CKCID_OBJECT", "CKCID_PARAMETER", "CKCID_PARAMETEROUT"} },
{ LibCmo::CK_CLASSID::CKCID_INTERFACEOBJECTMANAGER, {"CKCID_OBJECT", "CKCID_INTERFACEOBJECTMANAGER"} },
{ LibCmo::CK_CLASSID::CKCID_CRITICALSECTION, {"CKCID_OBJECT", "CKCID_CRITICALSECTION"} },
{ LibCmo::CK_CLASSID::CKCID_LAYER, {"CKCID_OBJECT", "CKCID_LAYER"} },
{ LibCmo::CK_CLASSID::CKCID_PROGRESSIVEMESH, {"CKCID_OBJECT", "CKCID_PROGRESSIVEMESH"} },
{ LibCmo::CK_CLASSID::CKCID_SYNCHRO, {"CKCID_OBJECT", "CKCID_SYNCHRO"} },
{ LibCmo::CK_CLASSID::CKCID_OBJECTARRAY, {"CKCID_OBJECTARRAY"} },
{ LibCmo::CK_CLASSID::CKCID_SCENEOBJECTDESC, {"CKCID_SCENEOBJECTDESC"} },
{ LibCmo::CK_CLASSID::CKCID_ATTRIBUTEMANAGER, {"CKCID_ATTRIBUTEMANAGER"} },
{ LibCmo::CK_CLASSID::CKCID_MESSAGEMANAGER, {"CKCID_MESSAGEMANAGER"} },
{ LibCmo::CK_CLASSID::CKCID_COLLISIONMANAGER, {"CKCID_COLLISIONMANAGER"} },
{ LibCmo::CK_CLASSID::CKCID_OBJECTMANAGER, {"CKCID_OBJECTMANAGER"} },
{ LibCmo::CK_CLASSID::CKCID_FLOORMANAGER, {"CKCID_FLOORMANAGER"} },
{ LibCmo::CK_CLASSID::CKCID_RENDERMANAGER, {"CKCID_RENDERMANAGER"} },
{ LibCmo::CK_CLASSID::CKCID_BEHAVIORMANAGER, {"CKCID_BEHAVIORMANAGER"} },
{ LibCmo::CK_CLASSID::CKCID_INPUTMANAGER, {"CKCID_INPUTMANAGER"} },
{ LibCmo::CK_CLASSID::CKCID_PARAMETERMANAGER, {"CKCID_PARAMETERMANAGER"} },
{ LibCmo::CK_CLASSID::CKCID_GRIDMANAGER, {"CKCID_GRIDMANAGER"} },
{ LibCmo::CK_CLASSID::CKCID_SOUNDMANAGER, {"CKCID_SOUNDMANAGER"} },
{ LibCmo::CK_CLASSID::CKCID_TIMEMANAGER, {"CKCID_TIMEMANAGER"} },
{ LibCmo::CK_CLASSID::CKCID_CUIKBEHDATA, {"CKCID_CUIKBEHDATA"} },
{ LibCmo::CK_CLASSID::CKCID_MAXCLASSID, {"CKCID_MAXCLASSID"} },
{ LibCmo::CK_CLASSID::CKCID_MAXMAXCLASSID, {"CKCID_MAXMAXCLASSID"} }
};
void GetClassIdName(std::string& strl, LibCmo::CK_CLASSID cls) {
strl.clear();
const std::vector<const char*>* pHierarchy = GetEnumData<LibCmo::CK_CLASSID, std::vector<const char*>>(
_CkClassHierarchy, cls
);
if (pHierarchy != nullptr) {
strl = pHierarchy->back();
}
}
void GetClassIdHierarchy(std::string& strl, LibCmo::CK_CLASSID cls) {
strl.clear();
const std::vector<const char*>* pHierarchy = GetEnumData<LibCmo::CK_CLASSID, std::vector<const char*>>(
_CkClassHierarchy, cls
);
if (pHierarchy != nullptr) {
for (auto it = pHierarchy->begin(); it != pHierarchy->end(); ++it) {
if (it != pHierarchy->begin()) strl += " -> ";
strl += (*it);
}
}
}
void GetAccessibleFileSize(std::string& strl, uint64_t size) {
static double denominator = (double)0b1111111111;
// check bytes
if ((size >> 10) == UINT64_C(0)) {
StringHelper::StdstringPrintf(strl, "%" PRIu64 "Bytes", size);
return;
}
size >>= 10;
// check kb
if ((size >> 10) == UINT64_C(0)) {
StringHelper::StdstringPrintf(strl, "%.2lfKiB", size / denominator);
return;
}
size >>= 10;
// check mb
if ((size >> 10) == UINT64_C(0)) {
StringHelper::StdstringPrintf(strl, "%.2lfMiB", size / denominator);
return;
}
size >>= 10;
// otherwise gb
StringHelper::StdstringPrintf(strl, "%.2lfGiB", size / denominator);
return;
}
}
}

View File

@ -0,0 +1,18 @@
#pragma once
#include <VTConstants.hpp>
#include <string>
namespace Unvirt {
namespace AccessibleValue {
void GetClassIdName(std::string& strl, LibCmo::CK_CLASSID cls);
void GetCkErrorName(std::string& strl, LibCmo::CKERROR err);
void GetClassIdHierarchy(std::string& strl, LibCmo::CK_CLASSID cls);
void GetCkErrorDescription(std::string& strl, LibCmo::CKERROR err);
void GetAccessibleFileSize(std::string& strl, uint64_t size);
}
}

24
Unvirt/StringHelper.cpp Normal file
View File

@ -0,0 +1,24 @@
#include "StringHelper.hpp"
#include <stdexcept>
namespace Unvirt {
namespace StringHelper {
void StdstringPrintf(std::string& strl, const char* format, ...) {
va_list argptr;
va_start(argptr, format);
StdstringVPrintf(strl, format, argptr);
va_end(argptr);
}
void StdstringVPrintf(std::string& strl, const char* format, va_list argptr) {
int count = _vsnprintf(NULL, 0, format, argptr);
strl.resize(count);
int write_result = _vsnprintf(strl.data(), count, format, argptr);
if (write_result < 0 || write_result >= count) throw new std::length_error("Invalid write_result in _vsnprintf.");
}
}
}

13
Unvirt/StringHelper.hpp Normal file
View File

@ -0,0 +1,13 @@
#pragma once
#include <string>
#include <cstdarg>
namespace Unvirt {
namespace StringHelper {
void StdstringPrintf(std::string& strl, const char* format, ...);
void StdstringVPrintf(std::string& strl, const char* format, va_list argptr);
}
}

11
Unvirt/Unvirt.cpp Normal file
View File

@ -0,0 +1,11 @@
#include "AccessibleValue.hpp"
#include <cstdio>
int main(int argc, char* argv[]) {
std::string test;
Unvirt::AccessibleValue::GetClassIdHierarchy(test, LibCmo::CK_CLASSID::CKCID_TARGETCAMERA);
printf("%s\n", test.c_str());
Unvirt::AccessibleValue::GetCkErrorDescription(test, LibCmo::CKERROR::CKERR_OBSOLETEVIRTOOLS);
printf("%s\n", test.c_str());
return 0;
}

View File

@ -100,14 +100,14 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<CompileAs>CompileAsC</CompileAs>
<AdditionalIncludeDirectories>../LibCmo;$(SQLITE_HEADER_PATH);$(GLIB_EXTRA_INCLUDE_PATH);$(GLIB_INCLUDE_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../LibCmo;$(SQLITE_HEADER_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>glib-2.0.lib;sqlite3.lib;LibCmo.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)out\$(Platform)\$(Configuration)\LibCmo;$(SQLITE_WIN32_LIB_PATH);$(GLIB_WIN32_LIB_PATH)</AdditionalLibraryDirectories>
<AdditionalDependencies>sqlite3.lib;LibCmo.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)out\$(Platform)\$(Configuration)\LibCmo;$(SQLITE_WIN32_LIB_PATH)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -118,16 +118,16 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<CompileAs>CompileAsC</CompileAs>
<AdditionalIncludeDirectories>../LibCmo;$(SQLITE_HEADER_PATH);$(GLIB_EXTRA_INCLUDE_PATH);$(GLIB_INCLUDE_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../LibCmo;$(SQLITE_HEADER_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>glib-2.0.lib;sqlite3.lib;LibCmo.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)out\$(Platform)\$(Configuration)\LibCmo;$(SQLITE_WIN32_LIB_PATH);$(GLIB_WIN32_LIB_PATH)</AdditionalLibraryDirectories>
<AdditionalDependencies>sqlite3.lib;LibCmo.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)out\$(Platform)\$(Configuration)\LibCmo;$(SQLITE_WIN32_LIB_PATH)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -136,14 +136,14 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<CompileAs>CompileAsC</CompileAs>
<AdditionalIncludeDirectories>../LibCmo;$(SQLITE_HEADER_PATH);$(GLIB_EXTRA_INCLUDE_PATH);$(GLIB_INCLUDE_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../LibCmo;$(SQLITE_HEADER_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>glib-2.0.lib;sqlite3.lib;LibCmo.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)out\$(Platform)\$(Configuration)\LibCmo;$(SQLITE_WIN64_LIB_PATH);$(GLIB_WIN64_LIB_PATH)</AdditionalLibraryDirectories>
<AdditionalDependencies>sqlite3.lib;LibCmo.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)out\$(Platform)\$(Configuration)\LibCmo;$(SQLITE_WIN64_LIB_PATH)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -154,20 +154,26 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<CompileAs>CompileAsC</CompileAs>
<AdditionalIncludeDirectories>../LibCmo;$(SQLITE_HEADER_PATH);$(GLIB_EXTRA_INCLUDE_PATH);$(GLIB_INCLUDE_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../LibCmo;$(SQLITE_HEADER_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>glib-2.0.lib;sqlite3.lib;LibCmo.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)out\$(Platform)\$(Configuration)\LibCmo;$(SQLITE_WIN64_LIB_PATH);$(GLIB_WIN64_LIB_PATH)</AdditionalLibraryDirectories>
<AdditionalDependencies>sqlite3.lib;LibCmo.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)out\$(Platform)\$(Configuration)\LibCmo;$(SQLITE_WIN64_LIB_PATH)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="unvirt.c" />
<ClCompile Include="AccessibleValue.cpp" />
<ClCompile Include="StringHelper.cpp" />
<ClCompile Include="Unvirt.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="AccessibleValue.hpp" />
<ClInclude Include="StringHelper.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -15,8 +15,22 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="unvirt.c">
<ClCompile Include="Unvirt.cpp">
<Filter>Sources</Filter>
</ClCompile>
<ClCompile Include="AccessibleValue.cpp">
<Filter>Sources</Filter>
</ClCompile>
<ClCompile Include="StringHelper.cpp">
<Filter>Sources</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="AccessibleValue.hpp">
<Filter>Headers</Filter>
</ClInclude>
<ClInclude Include="StringHelper.hpp">
<Filter>Headers</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -1,5 +0,0 @@
int main(int argc, char* argv[]) {
return 0;
}