mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Fix warning: delete called on non-final that has virtual functions but non-virtual destructor (#1671)
This commit is contained in:
@@ -47,6 +47,8 @@ public:
|
||||
std::unordered_map<std::string, ObjectCreator> creators;
|
||||
|
||||
public:
|
||||
virtual ~NamedObjectFactory() = default;
|
||||
|
||||
virtual T* create(std::string name, PlayerbotAI* botAI)
|
||||
{
|
||||
size_t found = name.find("::");
|
||||
@@ -147,9 +149,7 @@ public:
|
||||
{
|
||||
contexts.push_back(context);
|
||||
for (const auto& iter : context->creators)
|
||||
{
|
||||
creators[iter.first] = iter.second;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -208,6 +208,7 @@ public:
|
||||
if (T* object = create(name, botAI))
|
||||
return created[name] = object;
|
||||
}
|
||||
|
||||
return created[name];
|
||||
}
|
||||
|
||||
@@ -236,7 +237,6 @@ public:
|
||||
for (auto i = contexts.begin(); i != contexts.end(); i++)
|
||||
{
|
||||
std::set<std::string> supported = (*i)->supports();
|
||||
|
||||
for (std::set<std::string>::const_iterator j = supported.begin(); j != supported.end(); ++j)
|
||||
result.insert(*j);
|
||||
}
|
||||
@@ -248,9 +248,7 @@ public:
|
||||
{
|
||||
std::set<std::string> result;
|
||||
for (typename std::unordered_map<std::string, T*>::const_iterator i = created.begin(); i != created.end(); i++)
|
||||
{
|
||||
result.insert(i->first);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -297,15 +295,14 @@ public:
|
||||
{
|
||||
factories.push_back(context);
|
||||
for (const auto& iter : context->creators)
|
||||
{
|
||||
creators[iter.first] = iter.second;
|
||||
}
|
||||
}
|
||||
|
||||
T* GetContextObject(const std::string& name, PlayerbotAI* botAI)
|
||||
{
|
||||
if (T* object = create(name, botAI))
|
||||
return object;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user