refactored EntityClass usage to only store being a miscmodel in miscmodel_is bool + set it on setting classname

* miscmodel filter: simplify and support miscmodels, defined by new way (xml .ent)
This commit is contained in:
Garux
2018-02-19 00:40:51 +03:00
parent feedf4919e
commit 1b673b1a76
7 changed files with 39 additions and 32 deletions

View File

@@ -100,14 +100,19 @@ inline const char* EntityClassAttributePair_getDescription( const EntityClassAtt
return EntityClassAttributePair_getName( attributePair );
}
inline bool classname_equal( const char* classname, const char* other ){
return string_equal_nocase( classname, other );
}
class EntityClass
{
public:
private:
CopiedString m_name;
public:
StringList m_parent;
bool fixedsize;
bool unknown; // wasn't found in source
bool miscmodel_is; // definable via model attribute presence in xml .ent definition
bool miscmodel_is; // also definable via model attribute presence in xml .ent definition
CopiedString m_miscmodel_key;
Vector3 mins;
Vector3 maxs;
@@ -131,6 +136,11 @@ bool inheritanceResolved;
bool sizeSpecified;
bool colorSpecified;
void name_set( const char* name_ ) {
m_name = name_;
miscmodel_is = ( string_equal_prefix_nocase( name(), "misc_" ) && string_equal_suffix_nocase( name(), "model" ) ) // misc_*model (also misc_model)
|| classname_equal( name(), "model_static" );
}
const char* name() const {
return m_name.c_str();
}
@@ -164,17 +174,6 @@ inline EntityClassAttributePair& EntityClass_insertAttribute( EntityClass& entit
}
inline bool classname_equal( const char* classname, const char* other ){
return string_equal_nocase( classname, other );
}
inline bool EntityClass_miscmodel_is( const EntityClass* entityClass ){
return entityClass->miscmodel_is
|| ( string_compare_nocase_n( entityClass->name(), "misc_", 5 ) == 0 && string_equal_nocase( entityClass->name() + string_length( entityClass->name() ) - 5, "model" ) ) // misc_*model (also misc_model)
|| classname_equal( entityClass->name(), "model_static" );
}
inline void buffer_write_colour_add( char buffer[128], const Colour3& colour ){
sprintf( buffer, "{%g %g %g}", colour[0], colour[1], colour[2] );
}
@@ -284,7 +283,7 @@ inline EntityClass* EClass_Create( const char* name, const Vector3& colour, cons
EntityClass *e = Eclass_Alloc();
e->free = &Eclass_Free;
e->m_name = name;
e->name_set( name );
e->color = colour;
eclass_capture_state( e );
@@ -300,7 +299,7 @@ inline EntityClass* EClass_Create_FixedSize( const char* name, const Vector3& co
EntityClass *e = Eclass_Alloc();
e->free = &Eclass_Free;
e->m_name = name;
e->name_set( name );
e->color = colour;
eclass_capture_state( e );