Codechange: replace 'const char *' script API parameters with std::string
This commit is contained in:
@@ -84,7 +84,7 @@ ScriptController::ScriptController(CompanyID company) :
|
||||
return ScriptObject::GetActiveInstance()->GetOpsTillSuspend();
|
||||
}
|
||||
|
||||
/* static */ int ScriptController::GetSetting(const char *name)
|
||||
/* static */ int ScriptController::GetSetting(const std::string &name)
|
||||
{
|
||||
return ScriptObject::GetActiveInstance()->GetSetting(name);
|
||||
}
|
||||
@@ -94,7 +94,7 @@ ScriptController::ScriptController(CompanyID company) :
|
||||
return _openttd_newgrf_version;
|
||||
}
|
||||
|
||||
/* static */ HSQOBJECT ScriptController::Import(const char *library, const char *class_name, int version)
|
||||
/* static */ HSQOBJECT ScriptController::Import(const std::string &library, const std::string &class_name, int version)
|
||||
{
|
||||
ScriptController *controller = ScriptObject::GetActiveInstance()->GetController();
|
||||
Squirrel *engine = ScriptObject::GetActiveInstance()->engine;
|
||||
@@ -152,7 +152,7 @@ ScriptController::ScriptController(CompanyID company) :
|
||||
sq_getstackobj(vm, -1, &obj);
|
||||
sq_pop(vm, 3);
|
||||
|
||||
if (StrEmpty(class_name)) return obj;
|
||||
if (class_name.empty()) return obj;
|
||||
|
||||
/* Now link the name the user wanted to our 'fake' class */
|
||||
sq_pushobject(vm, parent);
|
||||
|
@@ -125,7 +125,7 @@ public:
|
||||
* @param name The name of the setting.
|
||||
* @return the value for the setting, or -1 if the setting is not known.
|
||||
*/
|
||||
static int GetSetting(const char *name);
|
||||
static int GetSetting(const std::string &name);
|
||||
|
||||
/**
|
||||
* Get the OpenTTD version of this executable. The version is formatted
|
||||
@@ -201,7 +201,7 @@ public:
|
||||
* @return The loaded library object. If class_name is set, it is also available (under the scope of the import) under that name.
|
||||
* @note This command can be called from the global space, and does not need an instance.
|
||||
*/
|
||||
static HSQOBJECT Import(const char *library, const char *class_name, int version);
|
||||
static HSQOBJECT Import(const std::string &library, const std::string &class_name, int version);
|
||||
|
||||
private:
|
||||
typedef std::map<std::string, std::string, CaseInsensitiveComparator> LoadedLibraryList; ///< The type for loaded libraries.
|
||||
|
@@ -16,13 +16,13 @@
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
/* static */ bool ScriptGameSettings::IsValid(const char *setting)
|
||||
/* static */ bool ScriptGameSettings::IsValid(const std::string &setting)
|
||||
{
|
||||
const SettingDesc *sd = GetSettingFromName(setting);
|
||||
return sd != nullptr && sd->IsIntSetting();
|
||||
}
|
||||
|
||||
/* static */ SQInteger ScriptGameSettings::GetValue(const char *setting)
|
||||
/* static */ SQInteger ScriptGameSettings::GetValue(const std::string &setting)
|
||||
{
|
||||
if (!IsValid(setting)) return -1;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
return sd->AsIntSetting()->Read(&_settings_game);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptGameSettings::SetValue(const char *setting, SQInteger value)
|
||||
/* static */ bool ScriptGameSettings::SetValue(const std::string &setting, SQInteger value)
|
||||
{
|
||||
EnforceDeityOrCompanyModeValid(false);
|
||||
if (!IsValid(setting)) return false;
|
||||
|
@@ -44,7 +44,7 @@ public:
|
||||
* @note Results achieved in the past offer no guarantee for the future.
|
||||
* @return True if and only if the setting is valid.
|
||||
*/
|
||||
static bool IsValid(const char *setting);
|
||||
static bool IsValid(const std::string &setting);
|
||||
|
||||
/**
|
||||
* Gets the value of the game setting.
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
* @note Results achieved in the past offer no guarantee for the future.
|
||||
* @return The value for the setting.
|
||||
*/
|
||||
static SQInteger GetValue(const char *setting);
|
||||
static SQInteger GetValue(const std::string &setting);
|
||||
|
||||
/**
|
||||
* Sets the value of the game setting.
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
* @note Results achieved in the past offer no guarantee for the future.
|
||||
* @api -ai
|
||||
*/
|
||||
static bool SetValue(const char *setting, SQInteger value);
|
||||
static bool SetValue(const std::string &setting, SQInteger value);
|
||||
|
||||
/**
|
||||
* Checks whether the given vehicle-type is disabled for companies.
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
RawText::RawText(const char *text) : text(text)
|
||||
RawText::RawText(const std::string &text) : text(text)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -42,7 +42,7 @@ public:
|
||||
*/
|
||||
class RawText : public Text {
|
||||
public:
|
||||
RawText(const char *text);
|
||||
RawText(const std::string &text);
|
||||
|
||||
const std::string GetEncodedText() override { return this->text; }
|
||||
private:
|
||||
|
Reference in New Issue
Block a user