Skip to content

oCMobInter.state property causes confusions - should be named to original Save Game value "stateNum" #105

@JaXt0r

Description

@JaXt0r

Hi there,

Description

I'm recently implementing Save Games and reading+saving Vob values in my game. I came across this setting:
oCMobInter.state

I initially thought it is the current state of a Vob (e.g. Door is open / wheel is turned) but it's not.
Checking save games, Gothic is not storing values of current states.

As your comment in MovableObject.hh already suggests, it stores the stateNum aka numberOfStates.
Examples from a save game for World.zen (G1):

[% oCMobInter:oCMOB:zCVob 35585 51]
stateNum=int:1
--> All oCMobInter have value of 1.

[% oCMobLadder:oCMobInter:oCMOB:zCVob]
stateNum=int:3
--> OpenGothic is handling it dynamically based on size of Ladder: https://github.com/Try/OpenGothic/blob/master/game/world/objects/interactive.cpp#L98

[% oCMobWheel:oCMobInter:oCMOB:zCVob]
stateNum=int:16
--> Seems to be a fixed value for Wheels.

OpenGothic already created another property which is named stateNum and copies the Save Game state property into it.
https://github.com/Try/OpenGothic/blob/master/game/world/objects/interactive.cpp#L44-L45

auto& inter = reinterpret_cast<const zenkit::VInteractiveObject&>(vob);
stateNum      = inter.state;

Recommendation:

Change the following lines (description and property name)
https://github.com/GothicKit/ZenKit/blob/main/include/zenkit/vobs/MovableObject.hh#L112-L114

		/// \brief Contains number of states for an object.
		/// \see https://zk.gothickit.dev/engine/objects/oCMobInter/#stateNum
		std::int32_t stateNum;

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions