mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: use std::string for script library category
This commit is contained in:
parent
e035705239
commit
552d2f71a2
|
@ -129,11 +129,6 @@ bool AIInfo::CanLoadFromVersion(int version) const
|
|||
}
|
||||
|
||||
|
||||
AILibrary::~AILibrary()
|
||||
{
|
||||
free(this->category);
|
||||
}
|
||||
|
||||
/* static */ void AILibrary::RegisterAPI(Squirrel *engine)
|
||||
{
|
||||
/* Create the AILibrary class, and add the RegisterLibrary function */
|
||||
|
@ -154,7 +149,7 @@ AILibrary::~AILibrary()
|
|||
}
|
||||
|
||||
/* Cache the category */
|
||||
if (!library->CheckMethod("GetCategory") || !library->engine->CallStringMethodStrdup(*library->SQ_instance, "GetCategory", &library->category, MAX_GET_OPS)) {
|
||||
if (!library->CheckMethod("GetCategory") || !library->engine->CallStringMethod(*library->SQ_instance, "GetCategory", &library->category, MAX_GET_OPS)) {
|
||||
delete library;
|
||||
return SQ_ERROR;
|
||||
}
|
||||
|
|
|
@ -56,8 +56,7 @@ private:
|
|||
/** All static information from an AI library like name, version, etc. */
|
||||
class AILibrary : public ScriptInfo {
|
||||
public:
|
||||
AILibrary() : ScriptInfo(), category(nullptr) {};
|
||||
~AILibrary();
|
||||
AILibrary() : ScriptInfo() {};
|
||||
|
||||
/**
|
||||
* Register the functions of this class.
|
||||
|
@ -72,10 +71,10 @@ public:
|
|||
/**
|
||||
* Get the category this library is in.
|
||||
*/
|
||||
const char *GetCategory() const { return this->category; }
|
||||
const std::string &GetCategory() const { return this->category; }
|
||||
|
||||
private:
|
||||
const char *category; ///< The category this library is in.
|
||||
std::string category; ///< The category this library is in.
|
||||
};
|
||||
|
||||
#endif /* AI_INFO_HPP */
|
||||
|
|
|
@ -99,11 +99,6 @@ bool GameInfo::CanLoadFromVersion(int version) const
|
|||
}
|
||||
|
||||
|
||||
GameLibrary::~GameLibrary()
|
||||
{
|
||||
free(this->category);
|
||||
}
|
||||
|
||||
/* static */ void GameLibrary::RegisterAPI(Squirrel *engine)
|
||||
{
|
||||
/* Create the GameLibrary class, and add the RegisterLibrary function */
|
||||
|
@ -124,7 +119,7 @@ GameLibrary::~GameLibrary()
|
|||
}
|
||||
|
||||
/* Cache the category */
|
||||
if (!library->CheckMethod("GetCategory") || !library->engine->CallStringMethodStrdup(*library->SQ_instance, "GetCategory", &library->category, MAX_GET_OPS)) {
|
||||
if (!library->CheckMethod("GetCategory") || !library->engine->CallStringMethod(*library->SQ_instance, "GetCategory", &library->category, MAX_GET_OPS)) {
|
||||
delete library;
|
||||
return SQ_ERROR;
|
||||
}
|
||||
|
|
|
@ -48,8 +48,7 @@ private:
|
|||
/** All static information from an Game library like name, version, etc. */
|
||||
class GameLibrary : public ScriptInfo {
|
||||
public:
|
||||
GameLibrary() : ScriptInfo(), category(nullptr) {};
|
||||
~GameLibrary();
|
||||
GameLibrary() : ScriptInfo() {};
|
||||
|
||||
/**
|
||||
* Register the functions of this class.
|
||||
|
@ -64,10 +63,10 @@ public:
|
|||
/**
|
||||
* Get the category this library is in.
|
||||
*/
|
||||
const char *GetCategory() const { return this->category; }
|
||||
const std::string &GetCategory() const { return this->category; }
|
||||
|
||||
private:
|
||||
const char *category; ///< The category this library is in.
|
||||
std::string category; ///< The category this library is in.
|
||||
};
|
||||
|
||||
#endif /* GAME_INFO_HPP */
|
||||
|
|
Loading…
Reference in New Issue