Exemplo n.º 1
0
void EntityClass_resolveInheritance( EntityClass* derivedClass ){
	if ( derivedClass->inheritanceResolved == false ) {
		derivedClass->inheritanceResolved = true;
		EntityClasses::iterator i = g_EntityClassDoom3_classes.find( derivedClass->m_parent.front().c_str() );
		if ( i == g_EntityClassDoom3_classes.end() ) {
			globalErrorStream() << "failed to find entityDef " << makeQuoted( derivedClass->m_parent.front().c_str() ) << " inherited by "  << makeQuoted( derivedClass->m_name.c_str() ) << "\n";
		}
		else
		{
			EntityClass* parentClass = ( *i ).second;
			EntityClass_resolveInheritance( parentClass );
			if ( !derivedClass->colorSpecified ) {
				derivedClass->colorSpecified = parentClass->colorSpecified;
				derivedClass->color = parentClass->color;
			}
			if ( !derivedClass->sizeSpecified ) {
				derivedClass->sizeSpecified = parentClass->sizeSpecified;
				derivedClass->mins = parentClass->mins;
				derivedClass->maxs = parentClass->maxs;
				derivedClass->fixedsize = parentClass->fixedsize;
			}

			for ( EntityClassAttributes::iterator j = parentClass->m_attributes.begin(); j != parentClass->m_attributes.end(); ++j )
			{
				EntityClass_insertAttribute( *derivedClass, ( *j ).first.c_str(), ( *j ).second );
			}
		}
	}
}
Exemplo n.º 2
0
void EntityClassDoom3_clear(){
	for ( EntityClasses::iterator i = g_EntityClassDoom3_classes.begin(); i != g_EntityClassDoom3_classes.end(); ++i )
	{
		( *i ).second->free( ( *i ).second );
	}
	g_EntityClassDoom3_classes.clear();
}
Exemplo n.º 3
0
void CleanEntityList(EntityClasses& entityClasses)
{
  for(EntityClasses::iterator i = entityClasses.begin(); i != entityClasses.end(); ++i)
  {
    (*i).second->free((*i).second);
  }
  entityClasses.clear();
}
Exemplo n.º 4
0
void realise(){
	if ( --m_unrealised == 0 ) {
		globalOutputStream() << "searching vfs directory " << makeQuoted( "def" ) << " for *.def\n";
		GlobalFileSystem().forEachFile( "def/", "def", makeCallbackF(EntityClassDoom3_loadFile) );

		{
			for ( Models::iterator i = g_models.begin(); i != g_models.end(); ++i )
			{
				Model_resolveInheritance( ( *i ).first.c_str(), ( *i ).second );
			}
		}
		{
			for ( EntityClasses::iterator i = g_EntityClassDoom3_classes.begin(); i != g_EntityClassDoom3_classes.end(); ++i )
			{
				EntityClass_resolveInheritance( ( *i ).second );
				if ( !string_empty( ( *i ).second->m_modelpath.c_str() ) ) {
					Models::iterator j = g_models.find( ( *i ).second->m_modelpath );
					if ( j != g_models.end() ) {
						( *i ).second->m_modelpath = ( *j ).second.m_mesh;
						( *i ).second->m_skin = ( *j ).second.m_skin;
					}
				}
				eclass_capture_state( ( *i ).second );

				StringOutputStream usage( 256 );

				usage << "-------- NOTES --------\n";

				if ( !string_empty( ( *i ).second->m_comments.c_str() ) ) {
					usage << ( *i ).second->m_comments.c_str() << "\n";
				}

				usage << "\n-------- KEYS --------\n";

				for ( EntityClassAttributes::iterator j = ( *i ).second->m_attributes.begin(); j != ( *i ).second->m_attributes.end(); ++j )
				{
					const char* name = EntityClassAttributePair_getName( *j );
					const char* description = EntityClassAttributePair_getDescription( *j );
					if ( !string_equal( name, description ) ) {
						usage << EntityClassAttributePair_getName( *j ) << " : " << EntityClassAttributePair_getDescription( *j ) << "\n";
					}
				}

				( *i ).second->m_comments = usage.c_str();
			}
		}

		m_observers.realise();
	}
}
Exemplo n.º 5
0
EntityClass* EntityClassDoom3_findOrInsert( const char *name, bool has_brushes ){
	ASSERT_NOTNULL( name );

	if ( string_empty( name ) ) {
		return g_EntityClassDoom3_bad;
	}

	EntityClasses::iterator i = g_EntityClassDoom3_classes.find( name );
	if ( i != g_EntityClassDoom3_classes.end()
	     //&& string_equal((*i).first, name)
		 ) {
		return ( *i ).second;
	}

	EntityClass* e = EntityClass_Create_Default( name, has_brushes );
	EntityClass* inserted = EntityClassDoom3_insertUnique( e );
	ASSERT_MESSAGE( inserted == e, "" );
	return inserted;
}
Exemplo n.º 6
0
void EntityClassDoom3_forEach( EntityClassVisitor& visitor ){
	for ( EntityClasses::iterator i = g_EntityClassDoom3_classes.begin(); i != g_EntityClassDoom3_classes.end(); ++i )
	{
		visitor.visit( ( *i ).second );
	}
}
Exemplo n.º 7
0
// Resolve inheritance for this class
void Doom3EntityClass::resolveInheritance(EntityClasses& classmap)
{
    // If we have already resolved inheritance, do nothing
    if (_inheritanceResolved)
        return;

    // Lookup the parent name and return if it is not set. Also return if the
    // parent name is the same as our own classname, to avoid infinite
    // recursion.
    std::string parName = getAttribute("inherit").getValue();
    if (parName.empty() || parName == _name)
        return;

    // Find the parent entity class
    EntityClasses::iterator pIter = classmap.find(parName);
    if (pIter != classmap.end())
    {
        // Recursively resolve inheritance of parent
        pIter->second->resolveInheritance(classmap);

        // Copy attributes from the parent to the child, including editor keys
        pIter->second->forEachClassAttribute(
            std::bind(&copyInheritedAttribute, this, std::placeholders::_1), true
        );

        // Set our parent pointer
        _parent = pIter->second.get();
    }
    else
    {
        rWarning() << "[eclassmgr] Entity class "
                              << _name << " specifies unknown parent class "
                              << parName << std::endl;
    }

    // Set the resolved flag
    _inheritanceResolved = true;

    if (!getAttribute("model").getValue().empty())
    {
        // We have a model path (probably an inherited one)
        setModelPath(getAttribute("model").getValue());
    }

    if (getAttribute("editor_light").getValue() == "1" || getAttribute("spawnclass").getValue() == "idLight")
    {
        // We have a light
        setIsLight(true);
    }

    if (getAttribute("editor_transparent").getValue() == "1")
    {
        _colourTransparent = true;
    }

    // (Re)set the colour
    const EntityClassAttribute& colourAttr = getAttribute("editor_color");

    if (!colourAttr.getValue().empty())
    {
        setColour(string::convert<Vector3>(colourAttr.getValue()));
    }
    else
    {
        // If no colour is set, assign the default entity colour to this class
        static Vector3 defaultColour = ColourSchemes().getColour("default_entity");
        setColour(defaultColour);
    }
}
Exemplo n.º 8
0
// Resolve inheritance for this class
void Doom3EntityClass::resolveInheritance(EntityClasses& classmap)
{
	// If we have already resolved inheritance, do nothing
	if (_inheritanceResolved)
		return;
		
	// Lookup the parent name and return if it is not set. Also return if the
	// parent name is the same as our own classname, to avoid infinite
	// recursion.
	std::string parName = getAttribute("inherit").value;
	if (parName.empty() || parName == _name)
		return;

	// Find the parent entity class
	EntityClasses::iterator pIter = classmap.find(parName);
	if (pIter != classmap.end())
	{
		// Recursively resolve inheritance of parent
		pIter->second->resolveInheritance(classmap);

		// Copy attributes from the parent to the child, including editor keys
		AttributeCopyingVisitor visitor(*this);
		pIter->second->forEachClassAttribute(visitor, true);
	}
	else {
		globalWarningStream() << "[eclassmgr] Entity class "
				  << _name << " specifies parent "
				  << parName << " which is not found." << std::endl;
	} 

	// Set the resolved flag
	_inheritanceResolved = true;

	// Construct the inheritance list
	buildInheritanceChain();

	if (getAttribute("model").value != "") {
		// We have a model path (probably an inherited one)
		setModelPath(getAttribute("model").value);
	}

	if (getAttribute("editor_light").value == "1" || getAttribute("spawnclass").value == "idLight") {
		// We have a light
		setIsLight(true);
	}

	if (getAttribute("editor_transparent").value == "1")
	{
		_colourTransparent = true;
	}

	// (Re)set the colour
	const EntityClassAttribute& colourAttr = getAttribute("editor_color");

	if (!colourAttr.value.empty())
	{
		setColour(Vector3(colourAttr.value));
	}

	// Update the colour shader
	captureColour();
}