This commit is contained in:
Benau 2018-09-23 15:26:24 +08:00
parent 896768ebbe
commit 56e9be326e
3 changed files with 12 additions and 3 deletions

View File

@ -41,6 +41,7 @@ static std::vector<UserConfigParam*> all_params;
#include "utils/string_utils.hpp"
#include "utils/translation.hpp"
#include <algorithm>
#include <fstream>
#include <iostream>
#include <stdlib.h>
@ -53,9 +54,12 @@ const int UserConfig::m_current_config_version = 8;
// ----------------------------------------------------------------------------
UserConfigParam::~UserConfigParam()
{
// Now we have server config param so we cannot do this anymore,
// esp all params are kept until the closing of stk anyway
//all_params.remove(this);
if (m_can_be_deleted)
{
auto it = std::find(all_params.begin(), all_params.end(), this);
if (it != all_params.end())
all_params.erase(it);
}
} // ~UserConfigParam
// ----------------------------------------------------------------------------

View File

@ -66,6 +66,7 @@ class UserConfigParam
{
friend class GroupUserConfigParam;
protected:
bool m_can_be_deleted = true;
std::string m_param_name;
std::string m_comment;
public:

View File

@ -51,6 +51,7 @@ FloatServerConfigParam::FloatServerConfigParam(float default_value,
const char* comment)
: FloatUserConfigParam(param_name, comment)
{
m_can_be_deleted = false;
m_value = default_value;
m_default_value = default_value;
g_server_params.push_back(this);
@ -62,6 +63,7 @@ IntServerConfigParam::IntServerConfigParam(int default_value,
const char* comment)
: IntUserConfigParam(param_name, comment)
{
m_can_be_deleted = false;
m_value = default_value;
m_default_value = default_value;
g_server_params.push_back(this);
@ -73,6 +75,7 @@ BoolServerConfigParam::BoolServerConfigParam(bool default_value,
const char* comment)
: BoolUserConfigParam(param_name, comment)
{
m_can_be_deleted = false;
m_value = default_value;
m_default_value = default_value;
g_server_params.push_back(this);
@ -84,6 +87,7 @@ StringServerConfigParam::StringServerConfigParam(std::string default_value,
const char* comment)
: StringUserConfigParam(param_name, comment)
{
m_can_be_deleted = false;
m_value = default_value;
m_default_value = default_value;
g_server_params.push_back(this);