mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-30 18:25:16 +01:00
Close #11614: Require plugins to specify their license
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
# include "Plugin.h"
|
||||
|
||||
# include "../Diagnostic.h"
|
||||
# include "../OpenRCT2.h"
|
||||
# include "Duktape.hpp"
|
||||
|
||||
@@ -127,6 +128,7 @@ PluginMetadata Plugin::GetMetadata(const DukValue& dukMetadata)
|
||||
metadata.Name = TryGetString(dukMetadata["name"], "Plugin name not specified.");
|
||||
metadata.Version = TryGetString(dukMetadata["version"], "Plugin version not specified.");
|
||||
metadata.Type = ParsePluginType(TryGetString(dukMetadata["type"], "Plugin type not specified."));
|
||||
CheckForLicence(dukMetadata["licence"], metadata.Name);
|
||||
|
||||
auto dukMinApiVersion = dukMetadata["minApiVersion"];
|
||||
if (dukMinApiVersion.type() == DukValue::Type::NUMBER)
|
||||
@@ -161,4 +163,10 @@ PluginType Plugin::ParsePluginType(const std::string_view& type)
|
||||
throw std::invalid_argument("Unknown plugin type.");
|
||||
}
|
||||
|
||||
void Plugin::CheckForLicence(const DukValue& dukLicence, const std::string_view& pluginName)
|
||||
{
|
||||
if (dukLicence.type() != DukValue::Type::STRING || dukLicence.as_string().empty())
|
||||
log_error("Plugin %s does not specify a licence", pluginName.data());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user