preparing Context creation function

This commit is contained in:
yyc12345 2023-02-27 22:23:05 +08:00
parent 00a7e041c6
commit 95cb1f7c30
12 changed files with 463 additions and 247 deletions

View File

@ -89,6 +89,39 @@ struct XBitArray {
DWORD m_Size;
};
struct VxImageDescEx {
int Size; // Size of the structure
DWORD Flags; // Reserved for special formats (such as compressed ) 0 otherwise
int Width; // Width in pixel of the image
int Height; // Height in pixel of the image
union {
int BytesPerLine; // Pitch (width in bytes) of the image
int TotalImageSize; // For compressed image (DXT1...) the total size of the image
};
int BitsPerPixel; // Number of bits per pixel
union {
DWORD RedMask; // Mask for Red component
DWORD BumpDuMask; // Mask for Bump Du component
};
union {
DWORD GreenMask; // Mask for Green component
DWORD BumpDvMask; // Mask for Bump Dv component
};
union {
DWORD BlueMask; // Mask for Blue component
DWORD BumpLumMask; // Mask for Luminance component
};
DWORD AlphaMask; // Mask for Alpha component
short BytesPerColorEntry; // ColorMap Stride
short ColorMapEntries; // If other than 0 image is palletized
BYTE* ColorMap; // Palette colors
BYTE* Image; // Image
};
// <T, K> = <int, CK_ID>
typedef struct XFileObjectsTable::Entry {
CK_ID key;

View File

@ -81,7 +81,47 @@ namespace LibCmo {
};
CKDWORD d[2];
};
CKGUID(CKDWORD gd1 = 0, CKDWORD gd2 = 0) { d[0] = gd1; d[1] = gd2; }
constexpr CKGUID(CKDWORD gd1 = 0, CKDWORD gd2 = 0) : d1(gd1), d2(gd2) {}
CKGUID(const CKGUID& rhs) : d1(rhs.d1), d2(rhs.d2) {}
CKGUID& operator=(const CKGUID& rhs) {
this->d1 = rhs.d1;
this->d2 = rhs.d2;
}
bool operator ==(const CKGUID& rhs) const {
return ((this->d1 == rhs.d1) && (this->d2 == rhs.d2));
}
bool operator !=(const CKGUID& rhs) const {
return ((this->d1 != rhs.d1) || (this->d2 != rhs.d2));
}
bool operator <(const CKGUID& rhs) const {
if (this->d1 < rhs.d1) {
return true;
}
if (this->d1 == rhs.d1) {
return (this->d2 < rhs.d2);
}
return false;
}
bool operator <=(const CKGUID& rhs) const {
return (this->d1 <= rhs.d1);
}
bool operator >(const CKGUID& rhs) const {
if (this->d1 > rhs.d1) {
return true;
}
if (this->d1 == rhs.d1) {
return (this->d2 > rhs.d2);
}
return false;
}
bool operator >=(const CKGUID& rhs) const {
return (this->d1 >= rhs.d1);
}
};

View File

@ -1,236 +1,275 @@
#pragma once
#include "CKDefines.hpp"
#include <cinttypes>
#include <cstdint>
namespace LibCmo::CK2 {
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_PARAMETEROUT = 3,
CKCID_INTERFACEOBJECTMANAGER = 48,
CKCID_CRITICALSECTION = 49,
CKCID_LAYER = 51,
CKCID_PROGRESSIVEMESH = 54,
CKCID_SYNCHRO = 20,
namespace PredefinedGuids {
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 = static_cast<uint32_t>(-1),
constexpr const CKDWORD OBJECT_MANAGER_GUID1 = 0x7cbb3b91;
constexpr const CKDWORD ATTRIBUTE_MANAGER_GUID1 = 0x3d242466;
constexpr const CKDWORD MESSAGE_MANAGER_GUID1 = 0x466a0fac;
constexpr const CKDWORD FLOOR_MANAGER_GUID1 = 0x420936f9;
constexpr const CKDWORD COLLISION_MANAGER_GUID1 = 0x38244712;
constexpr const CKDWORD GRID_MANAGER_GUID1 = 0x7f004791;
constexpr const CKDWORD TIME_MANAGER_GUID1 = 0x89ce7b32;
constexpr const CKDWORD BEHAVIOR_MANAGER_GUID1 = 0x58d621ae;
constexpr const CKDWORD INPUT_MANAGER_GUID1 = 0xf787c904;
constexpr const CKDWORD SOUND_MANAGER_GUID1 = 0xdce135f6;
constexpr const CKDWORD MIDI_MANAGER_GUID1 = 0x594154a6;
constexpr const CKDWORD INTERFACE_MANAGER_GUID1 = 0x9a4b8e3d;
constexpr const CKDWORD RENDER_MANAGER_GUID1 = 0xa213c8d5;
constexpr const CKDWORD PARAMETER_MANAGER_GUID1 = 0x9ce57ab6;
constexpr const CKDWORD PATH_MANAGER_GUID1 = 0x15fd54b9;
constexpr const CKDWORD VARIABLE_MANAGER_GUID1 = 0x98cc3cc9;
CKCID_MAXCLASSID = 55,
CKCID_MAXMAXCLASSID = 128
};
constexpr const CKGUID OBJECT_MANAGER_GUID{ OBJECT_MANAGER_GUID1 ,0 };
constexpr const CKGUID ATTRIBUTE_MANAGER_GUID{ ATTRIBUTE_MANAGER_GUID1, 0 };
constexpr const CKGUID MESSAGE_MANAGER_GUID{ MESSAGE_MANAGER_GUID1 ,0 };
constexpr const CKGUID TIME_MANAGER_GUID{ TIME_MANAGER_GUID1 ,0 };
constexpr const CKGUID SOUND_MANAGER_GUID{ SOUND_MANAGER_GUID1 ,0 };
constexpr const CKGUID MIDI_MANAGER_GUID{ MIDI_MANAGER_GUID1 ,0 };
constexpr const CKGUID INPUT_MANAGER_GUID{ INPUT_MANAGER_GUID1 ,0 };
constexpr const CKGUID BEHAVIOR_MANAGER_GUID{ BEHAVIOR_MANAGER_GUID1 ,0 };
constexpr const CKGUID FLOOR_MANAGER_GUID{ FLOOR_MANAGER_GUID1 ,0 };
constexpr const CKGUID COLLISION_MANAGER_GUID{ COLLISION_MANAGER_GUID1 ,0 };
constexpr const CKGUID GRID_MANAGER_GUID{ GRID_MANAGER_GUID1 ,0 };
constexpr const CKGUID INTERFACE_MANAGER_GUID{ INTERFACE_MANAGER_GUID1 ,0 };
constexpr const CKGUID RENDER_MANAGER_GUID{ RENDER_MANAGER_GUID1 ,0 };
constexpr const CKGUID PARAMETER_MANAGER_GUID{ PARAMETER_MANAGER_GUID1 ,0 };
constexpr const CKGUID PATH_MANAGER_GUID{ PATH_MANAGER_GUID1 ,0 };
constexpr const CKGUID VARIABLE_MANAGER_GUID{ VARIABLE_MANAGER_GUID1 ,0 };
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
};
}
enum class CK_FILE_WRITEMODE : uint32_t {
CKFILE_UNCOMPRESSED = 0,
CKFILE_CHUNKCOMPRESSED_OLD = 1,
CKFILE_EXTERNALTEXTURES_OLD = 2,
CKFILE_FORVIEWER = 4,
CKFILE_WHOLECOMPRESSED = 8
};
enum class CK_LOAD_FLAGS : uint32_t {
CK_LOAD_ANIMATION = 1 << 0,
CK_LOAD_GEOMETRY = 1 << 1,
CK_LOAD_DEFAULT = CK_LOAD_GEOMETRY | CK_LOAD_ANIMATION,
CK_LOAD_ASCHARACTER = 1 << 2,
CK_LOAD_DODIALOG = 1 << 3,
CK_LOAD_AS_DYNAMIC_OBJECT = 1 << 4,
CK_LOAD_AUTOMATICMODE = 1 << 5,
CK_LOAD_CHECKDUPLICATES = 1 << 6,
CK_LOAD_CHECKDEPENDENCIES = 1 << 7,
CK_LOAD_ONLYBEHAVIORS = 1 << 8
};
enum class CK_FO_OPTIONS : uint32_t {
CK_FO_DEFAULT = 0,
CK_FO_RENAMEOBJECT,
CK_FO_REPLACEOBJECT,
CK_FO_DONTLOADOBJECT
};
enum class CK_PLUGIN_TYPE : uint32_t {
CKPLUGIN_BITMAP_READER = 0,
CKPLUGIN_SOUND_READER = 1,
CKPLUGIN_MODEL_READER = 2,
CKPLUGIN_MANAGER_DLL = 3,
CKPLUGIN_BEHAVIOR_DLL = 4,
CKPLUGIN_RENDERENGINE_DLL = 5,
CKPLUGIN_MOVIE_READER = 6,
CKPLUGIN_EXTENSION_DLL = 7
};
enum class CK_STATECHUNK_DATAVERSION : uint32_t {
CHUNKDATA_OLDVERSION = 0,
CHUNKDATA_BASEVERSION = 1,
CHUNK_WAVESOUND_VERSION2 = 2,
CHUNK_WAVESOUND_VERSION3 = 3,
CHUNK_MATERIAL_VERSION_ZTEST = 4,
CHUNK_MAJORCHANGE_VERSION = 5,
CHUNK_MACCHANGE_VERSION = 6,
CHUNK_WAVESOUND_VERSION4 = 7,
CHUNK_SCENECHANGE_VERSION = 8,
CHUNK_MESHCHANGE_VERSION = 9,
CHUNK_DEV_2_1 = 10,
CHUNKDATA_CURRENTVERSION = CHUNK_DEV_2_1
};
enum class CK_STATECHUNK_CHUNKVERSION : uint32_t {
CHUNK_VERSIONBASE = 0,
CHUNK_VERSION1 = 4,
CHUNK_VERSION2 = 5,
CHUNK_VERSION3 = 6,
CHUNK_VERSION4 = 7
};
enum class CK_STATECHUNK_CHUNKOPTIONS : uint32_t {
CHNK_OPTION_IDS = 0x01,
CHNK_OPTION_MAN = 0x02,
CHNK_OPTION_CHN = 0x04,
CHNK_OPTION_FILE = 0x08,
CHNK_OPTION_ALLOWDYN = 0x10,
CHNK_OPTION_LISTBIG = 0x20,
CHNK_DONTDELETE_PTR = 0x40,
CHNK_DONTDELETE_PARSER = 0x80
};
enum class CK_OBJECT_FLAGS : uint32_t {
CK_OBJECT_INTERFACEOBJ = 0x00000001,
CK_OBJECT_PRIVATE = 0x00000002,
CK_OBJECT_INTERFACEMARK = 0x00000004,
CK_OBJECT_FREEID = 0x00000008,
CK_OBJECT_TOBEDELETED = 0x00000010,
CK_OBJECT_NOTTOBESAVED = 0x00000020,
CK_OBJECT_VISIBLE = 0x00000040,
CK_OBJECT_NAMESHARED = 0x00000080,
CK_OBJECT_DYNAMIC = 0x00000108,
CK_OBJECT_HIERACHICALHIDE = 0x00000200,
CK_OBJECT_UPTODATE = 0x00000400,
CK_OBJECT_TEMPMARKER = 0x00000800,
CK_OBJECT_ONLYFORFILEREFERENCE = 0x00001000,
CK_OBJECT_NOTTOBEDELETED = 0x00002000,
CK_OBJECT_APPDATA = 0x00004000,
CK_OBJECT_SINGLEACTIVITY = 0x00008000,
CK_OBJECT_LOADSKIPBEOBJECT = 0x00010000,
CK_OBJECT_NOTTOBELISTEDANDSAVED = 0x00000023,
CK_PARAMETEROUT_SETTINGS = 0x00400000,
CK_PARAMETEROUT_PARAMOP = 0x00800000,
CK_PARAMETERIN_DISABLED = 0x01000000,
CK_PARAMETERIN_THIS = 0x02000000,
CK_PARAMETERIN_SHARED = 0x04000000,
CK_PARAMETEROUT_DELETEAFTERUSE = 0x08000000,
CK_OBJECT_PARAMMASK = 0x0FC00000,
CK_BEHAVIORIO_IN = 0x10000000,
CK_BEHAVIORIO_OUT = 0x20000000,
CK_BEHAVIORIO_ACTIVE = 0x40000000,
CK_OBJECT_IOTYPEMASK = 0x30000000,
CK_OBJECT_IOMASK = 0xF0000000,
CKBEHAVIORLINK_RESERVED = 0x10000000,
CKBEHAVIORLINK_ACTIVATEDLASTFRAME = 0x20000000,
CK_OBJECT_BEHAVIORLINKMASK = 0x30000000
};
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_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 = static_cast<uint32_t>(-1),
CKCID_MAXCLASSID = 55,
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
};
enum class CK_FILE_WRITEMODE : uint32_t {
CKFILE_UNCOMPRESSED = 0,
CKFILE_CHUNKCOMPRESSED_OLD = 1,
CKFILE_EXTERNALTEXTURES_OLD = 2,
CKFILE_FORVIEWER = 4,
CKFILE_WHOLECOMPRESSED = 8
};
enum class CK_LOAD_FLAGS : uint32_t {
CK_LOAD_ANIMATION = 1 << 0,
CK_LOAD_GEOMETRY = 1 << 1,
CK_LOAD_DEFAULT = CK_LOAD_GEOMETRY | CK_LOAD_ANIMATION,
CK_LOAD_ASCHARACTER = 1 << 2,
CK_LOAD_DODIALOG = 1 << 3,
CK_LOAD_AS_DYNAMIC_OBJECT = 1 << 4,
CK_LOAD_AUTOMATICMODE = 1 << 5,
CK_LOAD_CHECKDUPLICATES = 1 << 6,
CK_LOAD_CHECKDEPENDENCIES = 1 << 7,
CK_LOAD_ONLYBEHAVIORS = 1 << 8
};
enum class CK_FO_OPTIONS : uint32_t {
CK_FO_DEFAULT = 0,
CK_FO_RENAMEOBJECT,
CK_FO_REPLACEOBJECT,
CK_FO_DONTLOADOBJECT
};
enum class CK_PLUGIN_TYPE : uint32_t {
CKPLUGIN_BITMAP_READER = 0,
CKPLUGIN_SOUND_READER = 1,
CKPLUGIN_MODEL_READER = 2,
CKPLUGIN_MANAGER_DLL = 3,
CKPLUGIN_BEHAVIOR_DLL = 4,
CKPLUGIN_RENDERENGINE_DLL = 5,
CKPLUGIN_MOVIE_READER = 6,
CKPLUGIN_EXTENSION_DLL = 7
};
enum class CK_STATECHUNK_DATAVERSION : uint32_t {
CHUNKDATA_OLDVERSION = 0,
CHUNKDATA_BASEVERSION = 1,
CHUNK_WAVESOUND_VERSION2 = 2,
CHUNK_WAVESOUND_VERSION3 = 3,
CHUNK_MATERIAL_VERSION_ZTEST = 4,
CHUNK_MAJORCHANGE_VERSION = 5,
CHUNK_MACCHANGE_VERSION = 6,
CHUNK_WAVESOUND_VERSION4 = 7,
CHUNK_SCENECHANGE_VERSION = 8,
CHUNK_MESHCHANGE_VERSION = 9,
CHUNK_DEV_2_1 = 10,
CHUNKDATA_CURRENTVERSION = CHUNK_DEV_2_1
};
enum class CK_STATECHUNK_CHUNKVERSION : uint32_t {
CHUNK_VERSIONBASE = 0,
CHUNK_VERSION1 = 4,
CHUNK_VERSION2 = 5,
CHUNK_VERSION3 = 6,
CHUNK_VERSION4 = 7
};
enum class CK_STATECHUNK_CHUNKOPTIONS : uint32_t {
CHNK_OPTION_IDS = 0x01,
CHNK_OPTION_MAN = 0x02,
CHNK_OPTION_CHN = 0x04,
CHNK_OPTION_FILE = 0x08,
CHNK_OPTION_ALLOWDYN = 0x10,
CHNK_OPTION_LISTBIG = 0x20,
CHNK_DONTDELETE_PTR = 0x40,
CHNK_DONTDELETE_PARSER = 0x80
};
enum class CK_OBJECT_FLAGS : uint32_t {
CK_OBJECT_INTERFACEOBJ = 0x00000001,
CK_OBJECT_PRIVATE = 0x00000002,
CK_OBJECT_INTERFACEMARK = 0x00000004,
CK_OBJECT_FREEID = 0x00000008,
CK_OBJECT_TOBEDELETED = 0x00000010,
CK_OBJECT_NOTTOBESAVED = 0x00000020,
CK_OBJECT_VISIBLE = 0x00000040,
CK_OBJECT_NAMESHARED = 0x00000080,
CK_OBJECT_DYNAMIC = 0x00000108,
CK_OBJECT_HIERACHICALHIDE = 0x00000200,
CK_OBJECT_UPTODATE = 0x00000400,
CK_OBJECT_TEMPMARKER = 0x00000800,
CK_OBJECT_ONLYFORFILEREFERENCE = 0x00001000,
CK_OBJECT_NOTTOBEDELETED = 0x00002000,
CK_OBJECT_APPDATA = 0x00004000,
CK_OBJECT_SINGLEACTIVITY = 0x00008000,
CK_OBJECT_LOADSKIPBEOBJECT = 0x00010000,
CK_OBJECT_NOTTOBELISTEDANDSAVED = 0x00000023,
CK_PARAMETEROUT_SETTINGS = 0x00400000,
CK_PARAMETEROUT_PARAMOP = 0x00800000,
CK_PARAMETERIN_DISABLED = 0x01000000,
CK_PARAMETERIN_THIS = 0x02000000,
CK_PARAMETERIN_SHARED = 0x04000000,
CK_PARAMETEROUT_DELETEAFTERUSE = 0x08000000,
CK_OBJECT_PARAMMASK = 0x0FC00000,
CK_BEHAVIORIO_IN = 0x10000000,
CK_BEHAVIORIO_OUT = 0x20000000,
CK_BEHAVIORIO_ACTIVE = 0x40000000,
CK_OBJECT_IOTYPEMASK = 0x30000000,
CK_OBJECT_IOMASK = 0xF0000000,
CKBEHAVIORLINK_RESERVED = 0x10000000,
CKBEHAVIORLINK_ACTIVATEDLASTFRAME = 0x20000000,
CK_OBJECT_BEHAVIORLINKMASK = 0x30000000
};
}

View File

@ -0,0 +1,20 @@
#include "../CKManagers.hpp"
namespace LibCmo::CK2::CKManagerImplements {
CKBaseManager::CKBaseManager(CKMinContext* ctx, CK_ID ckid) {
}
CKBaseManager::~CKBaseManager() {
}
CKAttributeManager::CKAttributeManager(CKMinContext* ctx, CK_ID ckid) : CKBaseManager(ctx, ckid) {
}
CKAttributeManager::~CKAttributeManager() {
}
}

View File

@ -7,20 +7,21 @@ namespace LibCmo::CK2::CKManagerImplements {
class CKBaseManager {
public:
CKBaseManager();
CKBaseManager(CKMinContext* ctx, CK_ID ckid);
CKBaseManager(const CKBaseManager&) = delete;
CKBaseManager& operator=(const CKBaseManager&) = delete;
virtual ~CKBaseManager();
virtual CKERROR LoadData(CKStateChunk* statechunk, CKFileData::ShallowDocument* doc);
virtual CKStateChunk* SaveData(CKFileData::ShallowDocument* doc);
private:
};
class CKAttributeManager {
class CKAttributeManager : public CKBaseManager {
public:
CKAttributeManager();
CKAttributeManager(CKMinContext* ctx, CK_ID ckid);
CKAttributeManager(const CKAttributeManager&) = delete;
CKAttributeManager& operator=(const CKAttributeManager&) = delete;
virtual ~CKAttributeManager();

View File

@ -1,5 +1,7 @@
#include "VTUtils.hpp"
#include "CKMinContext.hpp"
#include "CKObjects.hpp"
#include "CKManagers.hpp"
namespace LibCmo::CK2 {
@ -13,7 +15,24 @@ namespace LibCmo::CK2 {
CKMinContext::CKMinContext() :
m_NameEncoding(), m_NameEncodingToken(EncodingHelper::ENCODING_TOKEN_DEFAULT),
m_TempFolder(),
m_PrintCallback(nullptr)
m_PrintCallback(nullptr),
// register CKObjects
m_ObjectsCreationMap{
{CK_CLASSID::CKCID_OBJECT, ([](CKMinContext* ctx, CK_ID id, CKSTRING name) ->CKObjectImplements::CKObject* { return new(std::nothrow) CKObjectImplements::CKObject(ctx, id, name); })},
{CK_CLASSID::CKCID_SCENEOBJECT, ([](CKMinContext* ctx, CK_ID id, CKSTRING name) ->CKObjectImplements::CKObject* { return new(std::nothrow) CKObjectImplements::CKSceneObject(ctx, id, name); })},
{CK_CLASSID::CKCID_BEOBJECT, ([](CKMinContext* ctx, CK_ID id, CKSTRING name) ->CKObjectImplements::CKObject* { return new(std::nothrow) CKObjectImplements::CKBeObject(ctx, id, name); })},
{CK_CLASSID::CKCID_GROUP, ([](CKMinContext* ctx, CK_ID id, CKSTRING name) ->CKObjectImplements::CKObject* { return new(std::nothrow) CKObjectImplements::CKGroup(ctx, id, name); })},
{CK_CLASSID::CKCID_MESH, ([](CKMinContext* ctx, CK_ID id, CKSTRING name) ->CKObjectImplements::CKObject* { return new(std::nothrow) CKObjectImplements::CKMesh(ctx, id, name); })},
{CK_CLASSID::CKCID_TEXTURE, ([](CKMinContext* ctx, CK_ID id, CKSTRING name) ->CKObjectImplements::CKObject* { return new(std::nothrow) CKObjectImplements::CKTexture(ctx, id, name); })},
{CK_CLASSID::CKCID_MATERIAL, ([](CKMinContext* ctx, CK_ID id, CKSTRING name) ->CKObjectImplements::CKObject* { return new(std::nothrow) CKObjectImplements::CKMaterial(ctx, id, name); })},
{CK_CLASSID::CKCID_RENDEROBJECT, ([](CKMinContext* ctx, CK_ID id, CKSTRING name) ->CKObjectImplements::CKObject* { return new(std::nothrow) CKObjectImplements::CKRenderObject(ctx, id, name); })},
{CK_CLASSID::CKCID_3DENTITY, ([](CKMinContext* ctx, CK_ID id, CKSTRING name) ->CKObjectImplements::CKObject* { return new(std::nothrow) CKObjectImplements::CK3dEntity(ctx, id, name); })},
{CK_CLASSID::CKCID_3DOBJECT, ([](CKMinContext* ctx, CK_ID id, CKSTRING name) ->CKObjectImplements::CKObject* { return new(std::nothrow) CKObjectImplements::CK3dObject(ctx, id, name); })}
},
// register CKBaseManagers
m_ManagersCreationMap{
{PredefinedGuids::ATTRIBUTE_MANAGER_GUID, ([](CKMinContext* ctx, CK_ID id) ->CKManagerImplements::CKBaseManager* { return new(std::nothrow) CKManagerImplements::CKAttributeManager(ctx, id); })},
}
{
// preset for temp folder
m_TempFolder = std::filesystem::temp_directory_path();

View File

@ -1,9 +1,11 @@
#pragma once
#include "CKDefines.hpp"
#include "CKObjects.hpp"
#include "CKEnums.hpp"
#include "VTEncoding.hpp"
#include <filesystem>
#include <map>
#include <functional>
namespace LibCmo::CK2 {
@ -23,7 +25,7 @@ namespace LibCmo::CK2 {
void DestroyCKObject(CKObjectImplements::CKObject* obj);
CKManagerImplements::CKBaseManager* CreateCKManager(CKGUID guid);
CKManagerImplements::CKBaseManager* GetCKManager(CKGUID guid);
CKManagerImplements::CKBaseManager* GetCKManager(CK_ID guid);
void DestroyCKManager(CKManagerImplements::CKBaseManager* mgr);
void GetUtf8String(std::string& native_name, std::string& u8_name);
@ -37,6 +39,12 @@ namespace LibCmo::CK2 {
private:
void RefetchEncodingToken(void);
std::map<CK_ID, CKObjectImplements::CKObject*> m_ObjectsList;
std::map<CK_ID, CKManagerImplements::CKBaseManager*> m_ManagersList;
std::map<CK_CLASSID, std::function<CKObjectImplements::CKObject* (CKMinContext*, CK_ID, CKSTRING)>> m_ObjectsCreationMap;
std::map<CKGUID, std::function<CKManagerImplements::CKBaseManager* (CKMinContext*, CK_ID)>> m_ManagersCreationMap;
std::string m_NameEncoding;
EncodingHelper::ENCODING_TOKEN m_NameEncodingToken;
std::filesystem::path m_TempFolder;

View File

@ -2,12 +2,55 @@
namespace LibCmo::CK2::CKObjectImplements {
CKObject::CKObject() {
CKObject::CKObject(CKMinContext* ctx, CK_ID ckid, CKSTRING name) :
m_ID(ckid), m_Context(ctx),
m_Name(name == nullptr ? "" : name), m_HasName(name != nullptr),
m_ObjectFlags(CK_OBJECT_FLAGS::CK_PARAMETERIN_DISABLED) {
;
}
CKObject::~CKObject() {
}
CKSceneObject::CKSceneObject(CKMinContext* ctx, CK_ID ckid, CKSTRING name) : CKObject(ctx, ckid, name) {
}
CKSceneObject::~CKSceneObject() {
}
CKBeObject::CKBeObject(CKMinContext* ctx, CK_ID ckid, CKSTRING name) : CKSceneObject(ctx, ckid, name) {
}
CKBeObject::~CKBeObject() {
}
CKGroup::CKGroup(CKMinContext* ctx, CK_ID ckid, CKSTRING name) : CKBeObject(ctx, ckid, name) {
}
CKGroup::~CKGroup() {
}
CKMesh::CKMesh(CKMinContext* ctx, CK_ID ckid, CKSTRING name) : CKBeObject(ctx, ckid, name) {
}
CKMesh::~CKMesh() {
}
CKTexture::CKTexture(CKMinContext* ctx, CK_ID ckid, CKSTRING name) : CKBeObject(ctx, ckid, name) {
}
CKMaterial::~CKMaterial() {
}
CKRenderObject::CKRenderObject(CKMinContext* ctx, CK_ID ckid, CKSTRING name) : CKBeObject(ctx, ckid, name) {
}
CKRenderObject::~CKRenderObject() {
}
CK3dEntity::CK3dEntity(CKMinContext* ctx, CK_ID ckid, CKSTRING name) : CKRenderObject(ctx, ckid, name) {
}
CK3dEntity::~CK3dEntity() {
}
CK3dObject::CK3dObject(CKMinContext* ctx, CK_ID ckid, CKSTRING name) : CK3dEntity(ctx, ckid, name) {
}
CK3dObject::~CK3dObject() {
}
}

View File

@ -7,14 +7,18 @@ namespace LibCmo::CK2::CKObjectImplements {
class CKObject {
public:
CKObject();
CKObject(CKMinContext* ctx, CK_ID ckid, CKSTRING name);
CKObject(const CKObject&) = delete;
CKObject& operator=(const CKObject&) = delete;
virtual ~CKObject();
CK_ID GetID(void) { return this->m_ID; }
CKSTRING GetName(void) { return this->m_Name.c_str(); }
void SetName(CKSTRING u8_name) { this->m_Name = u8_name; }
CKSTRING GetName(void) { return m_HasName ? this->m_Name.c_str() : nullptr; }
void SetName(CKSTRING u8_name) {
this->m_HasName = u8_name != nullptr;
if (this->m_HasName) this->m_Name = u8_name;
else this->m_Name.clear();
}
CK_OBJECT_FLAGS GetObjectFlags(void) { return this->m_ObjectFlags; }
void SetObjectFlags(CK_OBJECT_FLAGS flags) { this->m_ObjectFlags = flags; }
@ -24,13 +28,14 @@ namespace LibCmo::CK2::CKObjectImplements {
protected:
CK_ID m_ID;
std::string m_Name;
bool m_HasName;
CK_OBJECT_FLAGS m_ObjectFlags;
CKMinContext* m_Context;
};
class CKSceneObject : public CKObject {
public:
CKSceneObject();
CKSceneObject(CKMinContext* ctx, CK_ID ckid, CKSTRING name);
CKSceneObject(const CKSceneObject&) = delete;
CKSceneObject& operator=(const CKSceneObject&) = delete;
virtual ~CKSceneObject();
@ -42,7 +47,7 @@ namespace LibCmo::CK2::CKObjectImplements {
class CKBeObject : public CKSceneObject {
public:
CKBeObject();
CKBeObject(CKMinContext* ctx, CK_ID ckid, CKSTRING name);
CKBeObject(const CKBeObject&) = delete;
CKBeObject& operator=(const CKBeObject&) = delete;
virtual ~CKBeObject();
@ -54,7 +59,7 @@ namespace LibCmo::CK2::CKObjectImplements {
class CKGroup : public CKBeObject {
public:
CKGroup();
CKGroup(CKMinContext* ctx, CK_ID ckid, CKSTRING name);
CKGroup(const CKGroup&) = delete;
CKGroup& operator=(const CKGroup&) = delete;
virtual ~CKGroup();
@ -66,7 +71,7 @@ namespace LibCmo::CK2::CKObjectImplements {
class CKMesh : public CKBeObject {
public:
CKMesh();
CKMesh(CKMinContext* ctx, CK_ID ckid, CKSTRING name);
CKMesh(const CKMesh&) = delete;
CKMesh& operator=(const CKMesh&) = delete;
virtual ~CKMesh();
@ -78,7 +83,7 @@ namespace LibCmo::CK2::CKObjectImplements {
class CKTexture : public CKBeObject {
public:
CKTexture();
CKTexture(CKMinContext* ctx, CK_ID ckid, CKSTRING name);
CKTexture(const CKTexture&) = delete;
CKTexture& operator=(const CKTexture&) = delete;
virtual ~CKTexture();
@ -90,7 +95,7 @@ namespace LibCmo::CK2::CKObjectImplements {
class CKMaterial : public CKBeObject {
public:
CKMaterial();
CKMaterial(CKMinContext* ctx, CK_ID ckid, CKSTRING name);
CKMaterial(const CKMaterial&) = delete;
CKMaterial& operator=(const CKMaterial&) = delete;
virtual ~CKMaterial();
@ -102,7 +107,7 @@ namespace LibCmo::CK2::CKObjectImplements {
class CKRenderObject : public CKBeObject {
public:
CKRenderObject();
CKRenderObject(CKMinContext* ctx, CK_ID ckid, CKSTRING name);
CKRenderObject(const CKRenderObject&) = delete;
CKRenderObject& operator=(const CKRenderObject&) = delete;
~CKRenderObject();
@ -112,9 +117,9 @@ namespace LibCmo::CK2::CKObjectImplements {
};
class CK3dEntity : public CKBeObject {
class CK3dEntity : public CKRenderObject {
public:
CK3dEntity();
CK3dEntity(CKMinContext* ctx, CK_ID ckid, CKSTRING name);
CK3dEntity(const CK3dEntity&) = delete;
CK3dEntity& operator=(const CK3dEntity&) = delete;
virtual ~CK3dEntity();
@ -126,7 +131,7 @@ namespace LibCmo::CK2::CKObjectImplements {
class CK3dObject :public CK3dEntity {
public:
CK3dObject();
CK3dObject(CKMinContext* ctx, CK_ID ckid, CKSTRING name);
CK3dObject(const CK3dObject&) = delete;
CK3dObject& operator=(const CK3dObject&) = delete;
~CK3dObject();

View File

@ -132,11 +132,13 @@ namespace LibCmo::CK2 {
needed = dwsize + this->m_Parser.m_CurrentPos;
// try resizing it
this->ResizeBuffer(needed);
if (!this->ResizeBuffer(needed)) return false;
// update size
this->m_Parser.m_DataSize = needed;
}
return true;
}
bool CKStateChunk::Skip(CKDWORD DwordCount) {
@ -392,6 +394,8 @@ namespace LibCmo::CK2 {
std::memcpy(strl.data(), this->m_pData + this->m_Parser.m_CurrentPos, strByteSize);
this->m_Parser.m_CurrentPos += strDwordSize;
} else strl.clear();
return CKERROR::CKERR_OK;
}

View File

@ -178,6 +178,7 @@
<ClCompile Include="CKFile.cpp" />
<ClCompile Include="CKFileWriter.cpp" />
<ClCompile Include="CKGlobals.cpp" />
<ClCompile Include="CKManagerImplements\CKBaseManager.cpp" />
<ClCompile Include="CKMinContext.cpp" />
<ClCompile Include="CKObjectImplements\CKObject.cpp" />
<ClCompile Include="VTEncoding.cpp" />

View File

@ -51,6 +51,9 @@
<ClCompile Include="VTUtils.cpp">
<Filter>Sources</Filter>
</ClCompile>
<ClCompile Include="CKManagerImplements\CKBaseManager.cpp">
<Filter>Sources\CKManagerImplements</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="VTUtils.hpp">