Skip to content

Include metadata fields in schema#1

Merged
Poggicek merged 2 commits into
ValveResourceFormat:masterfrom
LionDoge:master
May 17, 2025
Merged

Include metadata fields in schema#1
Poggicek merged 2 commits into
ValveResourceFormat:masterfrom
LionDoge:master

Conversation

@LionDoge

Copy link
Copy Markdown
Contributor

This change includes metadata names and values in dumps for classes, enums, and fields. They can also contain interesting information to compare against in game updates. Metadata can have different value types, I only handle the primitive ones, as there could be more - such as ones that use custom data structures which could also change between engine revisions (e.g Pulse system bindings). These fields get put in comment format above the corresponding definition.

Metadata names that include some value are defined in a separate file as array of values that gets looked up when dumping. This list might not be exhaustive, and it also might change between engine revisions, but probably not that commonly.

Sample output:

// MGetKV3ClassDefaults
class C_INIT_InitialVelocityNoise : public CParticleFunctionInitializer
{
	// MPropertyFriendlyName = "absolute value"
	// MVectorIsCoordinate
	Vector m_vecAbsVal;
	// MPropertyFriendlyName = "invert abs value"
	// MVectorIsCoordinate
	Vector m_vecAbsValInv;
	// MPropertyFriendlyName = "spatial coordinate offset"
	// MVectorIsCoordinate
	CPerParticleVecInput m_vecOffsetLoc;
	// MPropertyFriendlyName = "time coordinate offset"
	CPerParticleFloatInput m_flOffset;
	// MPropertyFriendlyName = "output minimum"
	CPerParticleVecInput m_vecOutputMin;
	// MPropertyFriendlyName = "output maximum"
	CPerParticleVecInput m_vecOutputMax;
	// MPropertyFriendlyName = "time noise coordinate scale"
	CPerParticleFloatInput m_flNoiseScale;
	// MPropertyFriendlyName = "spatial noise coordinate scale"
	CPerParticleFloatInput m_flNoiseScaleLoc;
	// MPropertyFriendlyName = "input local space velocity (optional)"
	// MParticleInputOptional
	CParticleTransformInput m_TransformInput;
	// MPropertyFriendlyName = "ignore delta time"
	bool m_bIgnoreDt;
};

Note 1: I used compile time string hash (FNV1a) for efficient comparison when looking up metadata entries.
Note 2: Some more printable fields could be added (e.g for MNetworkVarNames that uses a compound value with a name and value) I think this could differ a bit between engines, so I didn't touch it yet, but we could still do a commit for that.

@Poggicek

Copy link
Copy Markdown
Collaborator

Looks good, since you took the list from source2gen you need to comply with their apache license, please add their license to the NOTICE file and that will do.

FNV32("MPropertyDescription"),
FNV32("MPropertyExtendedEditor"),
FNV32("MPropertyFriendlyName"),
FNV32("MPropertyFriendlyName"),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dupe

// These are used to determine if we can include the corresponding metadata entry value in the dump.
// Original list sourced from Source2Gen project.

constinit std::array string_metadata_entries = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is way too overengineered, we do not care about few ms of performance, but do care about the code readibility. I am for using std map with std strings that will get hashed in std lib itself and map it to an enum of the different type values. Then resolve those enums in a switch case to the proper string value.

@Poggicek

Copy link
Copy Markdown
Collaborator

I will do the changes and merge it in, no need to resolve these

@Poggicek Poggicek merged commit e800c4f into ValveResourceFormat:master May 17, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants