Commit 6939abb6 authored by Bkg2k's avatar Bkg2k

Improve default metadata management #2

parent f5105ae5
......@@ -90,9 +90,18 @@ MetadataDescriptor MetadataDescriptor::_Default = MetadataDescriptor::BuildDefau
MetadataDescriptor MetadataDescriptor::BuildDefaultValueMetadataDescriptor()
{
MetadataDescriptor defaultData("default");
TreeNode emptyGameNode;
emptyGameNode.first = GameNodeIdentifier;
defaultData.Deserialize(emptyGameNode, "");
int count = 0;
const MetadataFieldDescriptor* fields = GetMetadataFieldDescriptors(ObjectType::Game, count);
for(; --count >= 0; )
{
// Get field descriptor
const MetadataFieldDescriptor& field = fields[count];
// Set default value
(defaultData.*field.SetValueMethod())(field.DefaultValue());
}
return std::move(defaultData);
}
......
......@@ -20,7 +20,7 @@ class MetadataDescriptor
};
private:
//! Default value storage for fast dafault detection
//! Default value storage for fast default detection
static MetadataDescriptor _Default;
#ifdef _METADATA_STATS_
......@@ -101,10 +101,8 @@ class MetadataDescriptor
if (value.empty()) FreePString(string);
else
{
if (string == nullptr)
string = new std::string(value);
else
*string = value;
if (string == nullptr) string = new std::string();
*string = value;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment