-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(Archive): initial implementation of spec-compliance
This patch adapts the implementation of `ReadArchive` to properly support object references in archives. To do this, I added a new `Object` class which represents any ZenGin object and a new `read_object` API to `ReadArchive` which facilitates loading of a set of pre-defined ZenGin object types. This new API takes care of creating new object instances and resolving archive-internal references. This required changing the `VirtualObject` hierarchy to use `shared_ptr` instead of `unique_ptr` so the system is able to share references to archive objects without sacrificing memory safety.
- Loading branch information
1 parent
ad83918
commit 5a15d3d
Showing
24 changed files
with
808 additions
and
589 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright © 2023 GothicKit Contributors. | ||
// SPDX-License-Identifier: MIT | ||
#pragma once | ||
#include "Misc.hh" | ||
|
||
namespace zenkit { | ||
class ReadArchive; | ||
|
||
enum class ObjectType { | ||
zCVob = 0, ///< The base type for all VObs. | ||
zCVobLevelCompo = 1, ///< A basic VOb used for grouping other VObs. | ||
oCItem = 2, ///< A VOb representing an item | ||
oCNpc = 3, ///< A VOb representing an NPC | ||
zCMoverController = 4, | ||
zCVobScreenFX = 5, | ||
zCVobStair = 6, | ||
zCPFXController = 7, | ||
zCVobAnimate = 8, | ||
zCVobLensFlare = 9, | ||
zCVobLight = 10, | ||
zCVobSpot = 11, | ||
zCVobStartpoint = 12, | ||
zCMessageFilter = 13, | ||
zCCodeMaster = 14, | ||
zCTriggerWorldStart = 15, | ||
zCCSCamera = 16, | ||
zCCamTrj_KeyFrame = 17, | ||
oCTouchDamage = 18, | ||
zCTriggerUntouch = 19, | ||
zCEarthquake = 20, | ||
oCMOB = 21, ///< The base VOb type used for dynamic world objects. | ||
oCMobInter = 22, ///< The base VOb type used for interactive world objects. | ||
oCMobBed = 23, ///< A bed the player can sleep in. | ||
oCMobFire = 24, ///< A campfire the player can cook things on. | ||
oCMobLadder = 25, ///< A ladder the player can climb. | ||
oCMobSwitch = 26, ///< A switch or button the player can use. | ||
oCMobWheel = 27, ///< A grindstone the player can sharpen their weapon with. | ||
oCMobContainer = 28, ///< A container the player can open. | ||
oCMobDoor = 29, ///< A door the player can open. | ||
zCTrigger = 30, ///< The base VOb type used for all kinds of triggers. | ||
zCTriggerList = 31, ///< A collection of multiple triggers. | ||
oCTriggerScript = 32, ///< A trigger for calling a script function. | ||
oCTriggerChangeLevel = 33, ///< A trigger for changing the game world. | ||
oCCSTrigger = 34, ///< A cutscene trigger. | ||
zCMover = 35, | ||
zCVobSound = 36, ///< A VOb which emits a certain sound. | ||
zCVobSoundDaytime = 37, ///< A VOb which emits a sound only during a specified time. | ||
oCZoneMusic = 38, ///< A VOb which plays music from the soundtrack. | ||
oCZoneMusicDefault = 39, | ||
zCZoneZFog = 40, ///< A VOb which indicates a foggy area. | ||
zCZoneZFogDefault = 41, | ||
zCZoneVobFarPlane = 42, | ||
zCZoneVobFarPlaneDefault = 43, | ||
ignored = 44, | ||
unknown = 45, | ||
|
||
oCNpcTalent, | ||
zCEventManager, | ||
zCDecal, | ||
zCMesh, | ||
zCProgMeshProto, | ||
zCParticleFX, | ||
zCAICamera, | ||
zCModel, | ||
zCMorphMesh, | ||
oCAIHuman, | ||
oCAIVobMove, | ||
oCCSPlayer, | ||
zCSkyControler_Outdoor | ||
}; | ||
|
||
class Object ZKAPI { | ||
public: | ||
Object() = default; | ||
virtual ~Object() noexcept = default; | ||
[[nodiscard]] virtual ObjectType get_type() const = 0; | ||
|
||
virtual void load(ReadArchive& r, GameVersion version); | ||
}; | ||
} // namespace zenkit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.