Merge branch 'master' into jgrpp

# Conflicts:
#	.github/workflows/release-linux.yml
#	.github/workflows/release-macos.yml
#	src/industry_cmd.cpp
#	src/industry_cmd.h
#	src/network/core/http_curl.cpp
#	src/network/core/tcp_http.cpp
#	src/network/core/tcp_http.h
#	src/network/network_content.h
#	src/script/api/script_goal.cpp
#	src/script/api/script_industry.cpp
#	src/script/api/script_league.cpp
#	src/script/api/script_story_page.cpp
#	src/script/api/script_town.cpp
#	src/train.h
#	src/train_cmd.cpp
This commit is contained in:
Jonathan G Rennison
2023-03-04 01:11:51 +00:00
77 changed files with 1197 additions and 761 deletions

View File

@@ -11,21 +11,17 @@
#include "../../string_func.h"
#include "../../strings_func.h"
#include "script_text.hpp"
#include "../script_fatalerror.hpp"
#include "../../table/control_codes.h"
#include "table/strings.h"
#include "../../safeguards.h"
RawText::RawText(const char *text) : text(stredup(text))
RawText::RawText(const char *text) : text(text)
{
}
RawText::~RawText()
{
free(this->text);
}
ScriptText::ScriptText(HSQUIRRELVM vm) :
string(STR_NULL), params(), parami(), paramt(), paramc(0)
@@ -176,12 +172,13 @@ SQInteger ScriptText::_set(HSQUIRRELVM vm)
return this->_SetParam(k, vm);
}
const char *ScriptText::GetEncodedText()
const std::string ScriptText::GetEncodedText()
{
static char buf[1024];
int param_count = 0;
this->_GetEncodedText(buf, lastof(buf), param_count);
return (param_count > SCRIPT_TEXT_MAX_PARAMETERS) ? nullptr : buf;
if (param_count > SCRIPT_TEXT_MAX_PARAMETERS) throw Script_FatalError("A string had too many parameters");
return buf;
}
char *ScriptText::_GetEncodedText(char *p, char *lastofp, int &param_count)
@@ -206,10 +203,9 @@ char *ScriptText::_GetEncodedText(char *p, char *lastofp, int &param_count)
return p;
}
const char *Text::GetDecodedText()
const std::string Text::GetDecodedText()
{
const char *encoded_text = this->GetEncodedText();
if (encoded_text == nullptr) return nullptr;
const std::string &encoded_text = this->GetEncodedText();
static char buf[1024];
::SetDParamStr(0, encoded_text);