mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-10 08:00:05 +00:00
Codechange: Remove ZeroedMemoryAllocator from ScriptText. (#13108)
ScriptText is much simplified from its original design. Use member initialisation instead.
This commit is contained in:
parent
13da98dab8
commit
6d3adc6169
@ -20,13 +20,8 @@
|
|||||||
|
|
||||||
#include "../../safeguards.h"
|
#include "../../safeguards.h"
|
||||||
|
|
||||||
RawText::RawText(const std::string &text) : text(text)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
ScriptText::ScriptText(HSQUIRRELVM vm)
|
||||||
ScriptText::ScriptText(HSQUIRRELVM vm) :
|
|
||||||
ZeroedMemoryAllocator()
|
|
||||||
{
|
{
|
||||||
int nparam = sq_gettop(vm) - 1;
|
int nparam = sq_gettop(vm) - 1;
|
||||||
if (nparam < 1) {
|
if (nparam < 1) {
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#define SCRIPT_TEXT_HPP
|
#define SCRIPT_TEXT_HPP
|
||||||
|
|
||||||
#include "script_object.hpp"
|
#include "script_object.hpp"
|
||||||
#include "../../core/alloc_type.hpp"
|
|
||||||
|
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
@ -42,7 +41,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
class RawText : public Text {
|
class RawText : public Text {
|
||||||
public:
|
public:
|
||||||
RawText(const std::string &text);
|
RawText(const std::string &text) : text(text) {}
|
||||||
|
|
||||||
std::string GetEncodedText() override { return this->text; }
|
std::string GetEncodedText() override { return this->text; }
|
||||||
private:
|
private:
|
||||||
@ -72,7 +71,7 @@ private:
|
|||||||
*
|
*
|
||||||
* @api game
|
* @api game
|
||||||
*/
|
*/
|
||||||
class ScriptText : public Text , public ZeroedMemoryAllocator {
|
class ScriptText : public Text {
|
||||||
public:
|
public:
|
||||||
static const int SCRIPT_TEXT_MAX_PARAMETERS = 20; ///< The maximum amount of parameters you can give to one object.
|
static const int SCRIPT_TEXT_MAX_PARAMETERS = 20; ///< The maximum amount of parameters you can give to one object.
|
||||||
|
|
||||||
@ -136,10 +135,10 @@ private:
|
|||||||
StringID owner;
|
StringID owner;
|
||||||
int idx;
|
int idx;
|
||||||
Param *param;
|
Param *param;
|
||||||
bool used;
|
bool used = false;
|
||||||
const char *cmd;
|
const char *cmd = nullptr;
|
||||||
|
|
||||||
ParamCheck(StringID owner, int idx, Param *param) : owner(owner), idx(idx), param(param), used(false), cmd(nullptr) {}
|
ParamCheck(StringID owner, int idx, Param *param) : owner(owner), idx(idx), param(param) {}
|
||||||
|
|
||||||
void Encode(std::back_insert_iterator<std::string> &output, const char *cmd);
|
void Encode(std::back_insert_iterator<std::string> &output, const char *cmd);
|
||||||
};
|
};
|
||||||
@ -148,8 +147,8 @@ private:
|
|||||||
using ParamSpan = std::span<ParamCheck>;
|
using ParamSpan = std::span<ParamCheck>;
|
||||||
|
|
||||||
StringID string;
|
StringID string;
|
||||||
Param param[SCRIPT_TEXT_MAX_PARAMETERS];
|
std::array<Param, SCRIPT_TEXT_MAX_PARAMETERS> param = {};
|
||||||
int paramc;
|
int paramc = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal function to recursively fill a list of parameters.
|
* Internal function to recursively fill a list of parameters.
|
||||||
|
Loading…
Reference in New Issue
Block a user