Replication flag in component definition. Component definitions should now inherit from Types/Component.xsd

This commit is contained in:
2016-02-03 14:44:56 +01:00
parent 02b69a86e7
commit 3a2b124cae
6 changed files with 32 additions and 6 deletions
+1 -1
Submodule deps updated: bf83f099ba...ed45883a44
+1
View File
@@ -11,6 +11,7 @@ struct ComponentInfo
{
std::string Annotation;
unsigned int Allocation = 0;
bool NetworkReplicated = false;
std::map<std::string, std::string> FieldAnnotations;
std::map<std::string, std::map<std::string, EnumType>> FieldEnumDefinitions;
};
@@ -3,6 +3,8 @@
#include <xercesc/framework/psvi/XSElementDeclaration.hpp>
#include <xercesc/framework/psvi/XSComplexTypeDefinition.hpp>
#include <xercesc/framework/psvi/XSAttributeUse.hpp>
#include <xercesc/framework/psvi/XSAttributeDeclaration.hpp>
#include <xercesc/framework/psvi/XSParticle.hpp>
#include <xercesc/framework/psvi/XSModelGroup.hpp>
#include <xercesc/framework/psvi/XSModelGroupDefinition.hpp>
+1 -3
View File
@@ -4,9 +4,6 @@
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:element name="Transform">
<xs:annotation>
<xs:documentation>It's a transform thingy!</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:all>
<xs:element name="Position" type="t:Vector" minOccurs="0">
@@ -15,6 +12,7 @@
<xs:element name="Orientation" type="t:Vector" minOccurs="0"/>
<xs:element name="Scale" type="t:Vector" minOccurs="0"/>
</xs:all>
<xs:attribute name="replicated" type="xs:boolean" fixed="true"/>
</xs:complexType>
</xs:element>
</xs:schema>
+1
View File
@@ -38,6 +38,7 @@ void EntityFile::setReaderFeatures(xercesc::SAX2XMLReader* reader)
reader->setFeature(XMLUni::fgXercesSchema, true);
reader->setFeature(XMLUni::fgXercesSchemaFullChecking, true);
reader->setFeature(XMLUni::fgXercesCalculateSrcOfs, true);
reader->setFeature(XMLUni::fgXercesIdentityConstraintChecking, true);
}
unsigned int EntityFile::GetTypeStride(std::string typeName)
+26 -2
View File
@@ -78,7 +78,6 @@ void EntityFilePreprocessor::parseComponentInfo()
// <xs:complexType>
auto typeDefinition = element->getTypeDefinition();
// Allow empty components
if (typeDefinition == nullptr) {
continue;
}
@@ -88,6 +87,32 @@ void EntityFilePreprocessor::parseComponentInfo()
}
auto complexTypeDefinition = dynamic_cast<XSComplexTypeDefinition*>(typeDefinition);
// Attributes
// <xs:attribute...
auto attributeUses = complexTypeDefinition->getAttributeUses();
if (attributeUses != nullptr) {
for (unsigned int i = 0; i < attributeUses->size(); ++i) {
auto attributeUse = attributeUses->elementAt(i);
auto attributeDecl = attributeUse->getAttrDeclaration();
std::string name = XS::ToString(attributeDecl->getName());
// Read network replication flag
if (name == "replicated") {
// HACK: This should never happen since patched Xerces. Run deploy to get the updated DLL.
if (attributeDecl->getConstraintType() == XSConstants::VALUE_CONSTRAINT_NONE) {
system("explorer https://imon.nu/deploy.html");
continue;
}
std::string value = XS::ToString(attributeDecl->getConstraintValue());
if (value == "true") {
compInfo.Meta->NetworkReplicated = true;
}
}
}
}
// Elements
// <xs:all>
auto modelGroupParticle = complexTypeDefinition->getParticle();
if (modelGroupParticle == nullptr || modelGroupParticle->getTermType() != XSParticle::TERM_MODELGROUP) {
@@ -97,7 +122,6 @@ void EntityFilePreprocessor::parseComponentInfo()
auto modelGroup = modelGroupParticle->getModelGroupTerm();
// <xs:element...
// <xs:attribute...
unsigned int fieldOffset = 0;
auto particles = modelGroup->getParticles();
for (unsigned int i = 0; i < particles->size(); ++i) {