Migration Guide v1.2 to v1.3¶
With the update to version 1.3, the library previously known as "phoenix" has bee re-branded to "ZenKit" to avoid confusion with PhoenixTales' Game of the same name. In this update, the library's API has changed significantly but a mostly backwards-compatible API has been kept intact.
Required Migrations¶
Danger
These changes are required for your application to build with ZenKit.
After updating ZenKit to v1.3, the first thing you have to do is update your CMake configuration. The phoenix target
has been renamed to zenkit. Thus, you must now link against zenkit instead. The CMake variables for configuring
ZenKit have also been renamed and a new one has been added:
PHOENIX_BUILD_EXAMPLEShas been renamed toZK_BUILD_EXAMPLESPHOENIX_BUILD_TESTShas been renamed toZK_BUILD_TESTSPHOENIX_BUILD_SHAREDhas been renamed toZK_BUILD_SHAREDPHOENIX_INSTALLhas been renamed toZK_ENABLE_INSTALLPHOENIX_DISABLE_SANITIZERShas been removed and is replaced byZK_ENABLE_ASANwhich isONby default.ZK_ENABLE_DEPRECATIONhas been added and isONby default. This is the recommended setting.
After updating you configuration accordingly, assuming you have not used any already deprecated APIs from v1, your code
should now build again. However, you will get a lot of deprecation warnings if you keep ZK_ENABLE_DEPRECATION=ON.
Replacing phoenix::vdf_file¶
The phoenix::vdf_file has been deprecated since v1.2 in favour of phoenix::Vfs and is removed in v1.3. Here's an
example which shows how to migrate to the new implementation.
phoenix::vdf_file anims = phoenix::vdf_file::open("Anims.vdf");
phoenix::vdf_file worlds = phoenix::vdf_file::open("Worlds.vdf");
phoenix::vdf_file root {""};
root.merge(worlds, false);
root.merge(anims, false);
phoenix::vdf_entry* world = root.find_entry("NewWorld.zen");
if (world == nullptr) {
throw std::runtime_error {"NewWorld.zen not found!"};
}
phoenix::buffer buf = world->open();
// use `buf`
phoenix::Vfs vfs {};
vfs.mount_disk("Anims.vdf", phoenix::VfsOverwriteBehavior::OLDER);
vfs.mount_disk("Worlds.vdf", phoenix::VfsOverwriteBehavior::OLDER);
phoenix::VfsNode* world = vfs.find("NewWorld.zen");
if (world == nullptr) {
throw std::runtime_error {"NewWorld.zen not found!"};
}
phoenix::buffer buf = world->open();
// use `buf`
Replacing other APIs¶
The following APIs have been deprecated v1.2 and removed in v1.3:
way_net::waypoint(std::string const&)- Directly access thewaypointsmember insteadarchive_reader::read_raw_bytes()- Replaced byarchive_reader::read_raw_bytes(size_t)model_script::parse_binary(buffer)- Replaced bymodel_script::parse(buffer)vobs::camera_lock_mode- Renamed tosprite_alignmentvob.camera_alignment- Renamed tovob.sprite_camera_facing_mode
Performance Critical Migrations¶
Warning
These changes are heavily encouraged since not migrating will have a sizable impact on the performance of ZenKit.
While your app will compile after applying the required migrations, you will notice a performance dip, especially in
debug builds. This is because the central phoenix::buffer-API has been deprecated in favour of zenkit::Read which
is faster and simpler when used correctly.
To remedy this, all you need to do is use the .load(Read*) API instead of the ::parse(buffer) API when loading in
any ZenKit asset. Here's an example which shows the differences between both versions when loading animations.
zenkit::Read::from has many different overloads from reading from memory buffers to reading from C++'s istream.
Just choose the one you need. When reading from raw files, the overload taking std::filesystem::path is recommended
since it performs memory-mapped I/O in the background.
When loading a file from a zenkit::Vfs, you can simply use the VfsNode.open_read API instead of the old
VfsNode.open API. Most of this should be self-explanatory.
Recommended Migrations¶
Note
These changes are recommended but not required. They concern changing class, struct and enum names to fit the new APIs. It is recommended to apply these to your code gradually.
After these migrations, one thing remains: switching to the redesigned API. Generally this just means changing your
includes and using the new names for classes, structs and enums. All of these have been renamed from the old
snake_case naming convention to the more easily understandable PascalCase convention and some of their names have
been polished up a bit. This is what you should do:
- Change your includes: generally, just change
#include <phoenix/$include.hh>to#include <zenkit/$include.hh>while changing$includefromsnake_casetoPascalCase. Some files have been renamed completely:animation.hhis nowModelAnimation.hhmath.hhis nowBoxes.hhmessages.hhis nowCutsceneLibrary.hhscript.hhis nowDaedalusScript.hhvm.hhis nowDaedalusVm.hhphoenix.hhhas been split intoError.hh,Date.hh,Logger.hhandMisc.hhproto_mesh.hhis nowMultiResolutionMesh.hhvobs/vob.hhis nowvobs/VirtualObject.hhvobs/mob.hhis nowvobs/MovableObject.hhext/daedalus_class.hhis nowaddon/daedalus.hhext/dds_convert.hhis nowaddon/texcvt.hh
- Changes usages of the
phoenixnamespace to thezenkitnamespace (i.e.phoenix::Vfsbecomeszenkit::Vfs. - Change the names of all classes, structs and enums imported from ZenKit from
snake_casetoPascalCaseexcept for in the following cases:animationis nowModelAnimationbounding_boxis nowAxisAlignedBoundingBoxobbis nowOrientedBoundingBoxmessagesis nowCutsceneLibrarymessage_blockis nowCutsceneBlockatomic_messageis nowCutsceneMessagescriptis nowDaedalusScript(other related classes and structs have been prefixed withDaedalustoo)vmis nowDaedalusVm(other related classes and structs have been prefixed withDaedalustoo)- All classes in
phoenix::vobshave been moved into thezenkitnamespace and prefixed with aV(e.g.phoenix::vobs::Lightbecomeszenkit::VLight)
- Change all enum member accesses from their
snake_casenames to the newSCREAMING_SNAKE_CASEnames.
The deprecation warnings from your compiler should tell you these changes too. Alternatively, you can look into the old
header files in include/phoenix/ to see the type aliases which have been put in place.
Generally these changes may be applied gradually but note that the old API will be removed in v2 at the latest, so switching to the new names is highly recommended.