Skip to content

Commit

Permalink
add_object: Require object class name, allow empty name
Browse files Browse the repository at this point in the history
  • Loading branch information
tobbi committed Aug 15, 2023
1 parent ca3a77a commit 011c79a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/scripting/sector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ Sector::add_object(const std::string& class_name, const std::string& name,
int posX, int posY, const std::string& direction,
const std::string& data)
{
if(name.empty())
if(class_name.empty())
{
log_fatal << "Object name cannot be empty" << std::endl;
log_fatal << "Object class name cannot be empty" << std::endl;
return;
}

if(m_parent->get_object_by_name<GameObject>(name) != nullptr)
if(!name.empty() && m_parent->get_object_by_name<GameObject>(name) != nullptr)
{
log_fatal << "Object with name " << name << " already exists in sector" << std::endl;
return;
Expand All @@ -66,7 +66,10 @@ Sector::add_object(const std::string& class_name, const std::string& name,
return;
}

obj->set_name(name);
if(!name.empty())
{
obj->set_name(name);
}
m_parent->add_object(std::move(obj));
}

Expand Down

0 comments on commit 011c79a

Please sign in to comment.