Skip to content

Commit

Permalink
#5893: Missing entityDefs should not end up with invalid colours
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jan 28, 2022
1 parent 58bf504 commit 9f0439c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion radiantcore/eclass/EntityClass.cpp
Expand Up @@ -171,7 +171,12 @@ void EntityClass::emplaceAttribute(EntityClassAttribute&& attribute)
EntityClass::Ptr EntityClass::create(const std::string& name, bool brushes)
{
vfs::FileInfo emptyFileInfo("def/", "_autogenerated_by_darkradiant_.def", vfs::Visibility::HIDDEN);
return std::make_shared<EntityClass>(name, emptyFileInfo, !brushes);
auto eclass = std::make_shared<EntityClass>(name, emptyFileInfo, !brushes);

// Force the entity class colour to default
eclass->setColour(UndefinedColour);

return eclass;
}

void EntityClass::forEachAttributeInternal(InternalAttrVisitor visitor,
Expand Down
8 changes: 8 additions & 0 deletions test/Entity.cpp
Expand Up @@ -722,6 +722,14 @@ TEST_F(EntityTest, DefaultEclassColourIsValid)
EXPECT_EQ(eclass->getColour(), Vector4(0.3, 0.3, 1, 1)) << "The entity class should have the same value as in EntityClass.cpp:DefaultEntityColour";
}

TEST_F(EntityTest, MissingEclassColourIsValid)
{
auto eclass = GlobalEntityClassManager().findOrInsert("___nonexistingeclass___", true);

EXPECT_EQ(eclass->getAttribute("editor_color", true).getValue(), "") << "Entity Class shouldn't have an editor_color in this test";
EXPECT_EQ(eclass->getColour(), Vector4(0.3, 0.3, 1, 1)) << "The entity class should have the same value as in EntityClass.cpp:DefaultEntityColour";
}

TEST_F(EntityTest, FuncStaticLocalToWorld)
{
auto funcStatic = createByClassName("func_static");
Expand Down

0 comments on commit 9f0439c

Please sign in to comment.