-
Notifications
You must be signed in to change notification settings - Fork 7
Include metadata fields in schema #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,98 @@ | ||
| /** | ||
| * ============================================================================= | ||
| * DumpSource2 | ||
| * Copyright (C) 2024 ValveResourceFormat Contributors | ||
| * | ||
| * Source2Gen | ||
| * Copyright (C) 2024 neverlosecc | ||
| * ============================================================================= | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify it under | ||
| * the terms of the GNU General Public License, version 3.0, as published by the | ||
| * Free Software Foundation. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
| * details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License along with | ||
| * this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
| #pragma once | ||
| #include <array> | ||
| #include "utils/hash.h" | ||
|
|
||
| // List of printable metadata entries that are not tied to any structures. | ||
| // 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 = { | ||
| FNV32("MCellForDomain"), | ||
| FNV32("MCustomFGDMetadata"), | ||
| FNV32("MFieldVerificationName"), | ||
| FNV32("MKV3TransferName"), | ||
| FNV32("MNetworkAlias"), | ||
| FNV32("MNetworkChangeCallback"), | ||
| FNV32("MNetworkEncoder"), | ||
| FNV32("MNetworkExcludeByName"), | ||
| FNV32("MNetworkExcludeByUserGroup"), | ||
| FNV32("MNetworkIncludeByName"), | ||
| FNV32("MNetworkIncludeByUserGroup"), | ||
| FNV32("MNetworkReplayCompatField"), | ||
| FNV32("MNetworkSerializer"), | ||
| FNV32("MNetworkTypeAlias"), | ||
| FNV32("MNetworkUserGroup"), | ||
| FNV32("MNetworkUserGroupProxy"), | ||
| FNV32("MParticleReplacementOp"), | ||
| FNV32("MPropertyArrayElementNameKey"), | ||
| FNV32("MPropertyAttributeChoiceName"), | ||
| FNV32("MPropertyAttributeEditor"), | ||
| FNV32("MPropertyAttributeRange"), | ||
| FNV32("MPropertyAttributeSuggestionName"), | ||
| FNV32("MPropertyCustomEditor"), | ||
| FNV32("MPropertyCustomFGDType"), | ||
| FNV32("MPropertyDescription"), | ||
| FNV32("MPropertyExtendedEditor"), | ||
| FNV32("MPropertyFriendlyName"), | ||
| FNV32("MPropertyFriendlyName"), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dupe |
||
| FNV32("MPropertyGroupName"), | ||
| FNV32("MPropertyIconName"), | ||
| FNV32("MPropertyStartGroup"), | ||
| FNV32("MPropertySuppressExpr"), | ||
| FNV32("MPulseEditorHeaderIcon"), | ||
| FNV32("MResourceBlockType"), | ||
| FNV32("MScriptDescription"), | ||
| FNV32("MSrc1ImportAttributeName"), | ||
| FNV32("MSrc1ImportDmElementType"), | ||
| FNV32("MVDataOutlinerIcon"), | ||
| FNV32("MVDataOutlinerIconExpr"), | ||
| FNV32("MVDataUniqueMonotonicInt"), | ||
| FNV32("MVectorIsSometimesCoordinate"), | ||
| }; | ||
|
|
||
| constinit std::array inline_string_metadata_entries = { | ||
| FNV32("MResourceTypeForInfoType"), | ||
| FNV32("MDiskDataForResourceType"), | ||
| }; | ||
|
|
||
| constinit std::array integer_metadata_entries = { | ||
| FNV32("MNetworkVarEmbeddedFieldOffsetDelta"), | ||
| FNV32("MNetworkBitCount"), | ||
| FNV32("MNetworkPriority"), | ||
| FNV32("MParticleOperatorType"), | ||
| FNV32("MPropertySortPriority"), | ||
| FNV32("MParticleMinVersion"), | ||
| FNV32("MParticleMaxVersion"), | ||
| FNV32("MNetworkEncodeFlags"), | ||
| FNV32("MResourceVersion"), | ||
| FNV32("MVDataNodeType"), | ||
| FNV32("MVDataOverlayType"), | ||
| FNV32("MAlignment"), | ||
| FNV32("MGenerateArrayKeynamesFirstIndex"), | ||
| }; | ||
|
|
||
| constinit std::array float_metadata_entries = { | ||
| FNV32("MNetworkMinValue"), | ||
| FNV32("MNetworkMaxValue"), | ||
| }; | ||
This file contains hidden or 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 hidden or 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,36 @@ | ||
| /** | ||
| * ============================================================================= | ||
| * DumpSource2 | ||
| * Copyright (C) 2024 ValveResourceFormat Contributors | ||
| * ============================================================================= | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify it under | ||
| * the terms of the GNU General Public License, version 3.0, as published by the | ||
| * Free Software Foundation. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
| * details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License along with | ||
| * this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #pragma once | ||
| #include <cstdint> | ||
| // FNV1a c++11 constexpr compile time hash functions, 32 and 64 bit | ||
| // str should be a null terminated string literal, value should be left out | ||
| // e.g hash_32_fnv1a_const("example") | ||
| // code license: public domain or equivalent | ||
| // post: https://notes.underscorediscovery.com/constexpr-fnv1a/ | ||
|
|
||
| constexpr uint32_t val_32_const = 0x811c9dc5; | ||
| constexpr uint32_t prime_32_const = 0x1000193; | ||
|
|
||
| inline constexpr uint32_t hash_32_fnv1a_const(const char* const str, const uint32_t value = val_32_const) noexcept { | ||
| return (str[0] == '\0') ? value : hash_32_fnv1a_const(&str[1], (value ^ uint32_t((uint8_t)str[0])) * prime_32_const); | ||
| } | ||
|
|
||
| // Short name to be less verbose | ||
| #define FNV32(str) hash_32_fnv1a_const(str) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.