Codechange: use std::string for script info/library finding

This commit is contained in:
Rubidium
2023-05-05 09:53:34 +02:00
committed by rubidium42
parent a30f7c83bd
commit 0fd9eb0faa
20 changed files with 35 additions and 38 deletions

View File

@@ -19,8 +19,7 @@
void ScriptConfig::Change(const char *name, int version, bool force_exact_match, bool is_random)
{
free(this->name);
this->name = (name == nullptr) ? nullptr : stredup(name);
this->name = (name == nullptr) ? "" : name;
this->info = (name == nullptr) ? nullptr : this->FindInfo(this->name, version, force_exact_match);
this->version = (info == nullptr) ? -1 : info->GetVersion();
this->is_random = is_random;
@@ -44,7 +43,7 @@ void ScriptConfig::Change(const char *name, int version, bool force_exact_match,
ScriptConfig::ScriptConfig(const ScriptConfig *config)
{
this->name = (config->name == nullptr) ? nullptr : stredup(config->name);
this->name = config->name;
this->info = config->info;
this->version = config->version;
this->is_random = config->is_random;
@@ -60,7 +59,6 @@ ScriptConfig::ScriptConfig(const ScriptConfig *config)
ScriptConfig::~ScriptConfig()
{
free(this->name);
this->ResetSettings();
this->to_load_data.reset();
}
@@ -156,7 +154,7 @@ bool ScriptConfig::IsRandom() const
return this->is_random;
}
const char *ScriptConfig::GetName() const
const std::string &ScriptConfig::GetName() const
{
return this->name;
}