mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 18:40:29 +00:00
Codechange: use std::string without const as return
Otherwise some compilers, e.g. MSVC, do not pick up that these are temporaries and as such it will pass the temporaries to `const std::string &` instead of the wanted `std::string &&`
This commit is contained in:
parent
b2edf82b69
commit
78f5d58dc6
@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
EnforceDeityMode(GOAL_INVALID);
|
EnforceDeityMode(GOAL_INVALID);
|
||||||
EnforcePrecondition(GOAL_INVALID, goal != nullptr);
|
EnforcePrecondition(GOAL_INVALID, goal != nullptr);
|
||||||
const std::string &text = goal->GetEncodedText();
|
std::string text = goal->GetEncodedText();
|
||||||
EnforcePreconditionEncodedText(GOAL_INVALID, text);
|
EnforcePreconditionEncodedText(GOAL_INVALID, text);
|
||||||
EnforcePrecondition(GOAL_INVALID, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID);
|
EnforcePrecondition(GOAL_INVALID, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID);
|
||||||
EnforcePrecondition(GOAL_INVALID, IsValidGoalDestination(company, type, destination));
|
EnforcePrecondition(GOAL_INVALID, IsValidGoalDestination(company, type, destination));
|
||||||
@ -84,7 +84,7 @@
|
|||||||
EnforcePrecondition(false, IsValidGoal(goal_id));
|
EnforcePrecondition(false, IsValidGoal(goal_id));
|
||||||
EnforceDeityMode(false);
|
EnforceDeityMode(false);
|
||||||
EnforcePrecondition(false, goal != nullptr);
|
EnforcePrecondition(false, goal != nullptr);
|
||||||
const std::string &text = goal->GetEncodedText();
|
std::string text = goal->GetEncodedText();
|
||||||
EnforcePreconditionEncodedText(false, text);
|
EnforcePreconditionEncodedText(false, text);
|
||||||
|
|
||||||
return ScriptObject::Command<CMD_SET_GOAL_TEXT>::Do(goal_id, text);
|
return ScriptObject::Command<CMD_SET_GOAL_TEXT>::Do(goal_id, text);
|
||||||
@ -123,7 +123,7 @@
|
|||||||
|
|
||||||
EnforceDeityMode(false);
|
EnforceDeityMode(false);
|
||||||
EnforcePrecondition(false, question != nullptr);
|
EnforcePrecondition(false, question != nullptr);
|
||||||
const std::string &text = question->GetEncodedText();
|
std::string text = question->GetEncodedText();
|
||||||
EnforcePreconditionEncodedText(false, text);
|
EnforcePreconditionEncodedText(false, text);
|
||||||
uint min_buttons = (type == QT_QUESTION ? 1 : 0);
|
uint min_buttons = (type == QT_QUESTION ? 1 : 0);
|
||||||
EnforcePrecondition(false, CountBits(buttons) >= min_buttons && CountBits(buttons) <= 3);
|
EnforcePrecondition(false, CountBits(buttons) >= min_buttons && CountBits(buttons) <= 3);
|
||||||
|
@ -32,11 +32,11 @@
|
|||||||
|
|
||||||
EnforceDeityMode(LEAGUE_TABLE_INVALID);
|
EnforceDeityMode(LEAGUE_TABLE_INVALID);
|
||||||
EnforcePrecondition(LEAGUE_TABLE_INVALID, title != nullptr);
|
EnforcePrecondition(LEAGUE_TABLE_INVALID, title != nullptr);
|
||||||
const std::string &encoded_title = title->GetEncodedText();
|
std::string encoded_title = title->GetEncodedText();
|
||||||
EnforcePreconditionEncodedText(LEAGUE_TABLE_INVALID, encoded_title);
|
EnforcePreconditionEncodedText(LEAGUE_TABLE_INVALID, encoded_title);
|
||||||
|
|
||||||
const std::string &encoded_header = (header != nullptr ? header->GetEncodedText() : std::string{});
|
std::string encoded_header = (header != nullptr ? header->GetEncodedText() : std::string{});
|
||||||
const std::string &encoded_footer = (footer != nullptr ? footer->GetEncodedText() : std::string{});
|
std::string encoded_footer = (footer != nullptr ? footer->GetEncodedText() : std::string{});
|
||||||
|
|
||||||
if (!ScriptObject::Command<CMD_CREATE_LEAGUE_TABLE>::Do(&ScriptInstance::DoCommandReturnLeagueTableID, encoded_title, encoded_header, encoded_footer)) return LEAGUE_TABLE_INVALID;
|
if (!ScriptObject::Command<CMD_CREATE_LEAGUE_TABLE>::Do(&ScriptInstance::DoCommandReturnLeagueTableID, encoded_title, encoded_header, encoded_footer)) return LEAGUE_TABLE_INVALID;
|
||||||
|
|
||||||
@ -63,11 +63,11 @@
|
|||||||
if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY;
|
if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY;
|
||||||
|
|
||||||
EnforcePrecondition(LEAGUE_TABLE_ELEMENT_INVALID, text != nullptr);
|
EnforcePrecondition(LEAGUE_TABLE_ELEMENT_INVALID, text != nullptr);
|
||||||
const std::string &encoded_text = text->GetEncodedText();
|
std::string encoded_text = text->GetEncodedText();
|
||||||
EnforcePreconditionEncodedText(LEAGUE_TABLE_ELEMENT_INVALID, encoded_text);
|
EnforcePreconditionEncodedText(LEAGUE_TABLE_ELEMENT_INVALID, encoded_text);
|
||||||
|
|
||||||
EnforcePrecondition(LEAGUE_TABLE_ELEMENT_INVALID, score != nullptr);
|
EnforcePrecondition(LEAGUE_TABLE_ELEMENT_INVALID, score != nullptr);
|
||||||
const std::string &encoded_score = score->GetEncodedText();
|
std::string encoded_score = score->GetEncodedText();
|
||||||
EnforcePreconditionEncodedText(LEAGUE_TABLE_ELEMENT_INVALID, encoded_score);
|
EnforcePreconditionEncodedText(LEAGUE_TABLE_ELEMENT_INVALID, encoded_score);
|
||||||
|
|
||||||
EnforcePrecondition(LEAGUE_TABLE_ELEMENT_INVALID, IsValidLink(Link((::LinkType)link_type, link_target)));
|
EnforcePrecondition(LEAGUE_TABLE_ELEMENT_INVALID, IsValidLink(Link((::LinkType)link_type, link_target)));
|
||||||
@ -90,7 +90,7 @@
|
|||||||
if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY;
|
if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY;
|
||||||
|
|
||||||
EnforcePrecondition(false, text != nullptr);
|
EnforcePrecondition(false, text != nullptr);
|
||||||
const std::string &encoded_text = text->GetEncodedText();
|
std::string encoded_text = text->GetEncodedText();
|
||||||
EnforcePreconditionEncodedText(false, encoded_text);
|
EnforcePreconditionEncodedText(false, encoded_text);
|
||||||
|
|
||||||
EnforcePrecondition(false, IsValidLink(Link((::LinkType)link_type, link_target)));
|
EnforcePrecondition(false, IsValidLink(Link((::LinkType)link_type, link_target)));
|
||||||
@ -106,7 +106,7 @@
|
|||||||
EnforcePrecondition(false, IsValidLeagueTableElement(element));
|
EnforcePrecondition(false, IsValidLeagueTableElement(element));
|
||||||
|
|
||||||
EnforcePrecondition(false, score != nullptr);
|
EnforcePrecondition(false, score != nullptr);
|
||||||
const std::string &encoded_score = score->GetEncodedText();
|
std::string encoded_score = score->GetEncodedText();
|
||||||
EnforcePreconditionEncodedText(false, encoded_score);
|
EnforcePreconditionEncodedText(false, encoded_score);
|
||||||
|
|
||||||
return ScriptObject::Command<CMD_UPDATE_LEAGUE_TABLE_ELEMENT_SCORE>::Do(element, rating, encoded_score);
|
return ScriptObject::Command<CMD_UPDATE_LEAGUE_TABLE_ELEMENT_SCORE>::Do(element, rating, encoded_score);
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
EnforceDeityMode(false);
|
EnforceDeityMode(false);
|
||||||
EnforcePrecondition(false, text != nullptr);
|
EnforcePrecondition(false, text != nullptr);
|
||||||
const std::string &encoded = text->GetEncodedText();
|
std::string encoded = text->GetEncodedText();
|
||||||
EnforcePreconditionEncodedText(false, encoded);
|
EnforcePreconditionEncodedText(false, encoded);
|
||||||
EnforcePrecondition(false, type == NT_ECONOMY || type == NT_SUBSIDIES || type == NT_GENERAL);
|
EnforcePrecondition(false, type == NT_ECONOMY || type == NT_SUBSIDIES || type == NT_GENERAL);
|
||||||
EnforcePrecondition(false, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID);
|
EnforcePrecondition(false, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID);
|
||||||
|
@ -158,7 +158,7 @@ SQInteger ScriptText::_set(HSQUIRRELVM vm)
|
|||||||
return this->_SetParam(k, vm);
|
return this->_SetParam(k, vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string ScriptText::GetEncodedText()
|
std::string ScriptText::GetEncodedText()
|
||||||
{
|
{
|
||||||
static StringIDList seen_ids;
|
static StringIDList seen_ids;
|
||||||
int param_count = 0;
|
int param_count = 0;
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
* @return A string.
|
* @return A string.
|
||||||
* @api -all
|
* @api -all
|
||||||
*/
|
*/
|
||||||
virtual const std::string GetEncodedText() = 0;
|
virtual std::string GetEncodedText() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a #ScriptText into a decoded normal string.
|
* Convert a #ScriptText into a decoded normal string.
|
||||||
@ -44,7 +44,7 @@ class RawText : public Text {
|
|||||||
public:
|
public:
|
||||||
RawText(const std::string &text);
|
RawText(const std::string &text);
|
||||||
|
|
||||||
const std::string GetEncodedText() override { return this->text; }
|
std::string GetEncodedText() override { return this->text; }
|
||||||
private:
|
private:
|
||||||
const std::string text;
|
const std::string text;
|
||||||
};
|
};
|
||||||
@ -125,7 +125,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @api -all
|
* @api -all
|
||||||
*/
|
*/
|
||||||
virtual const std::string GetEncodedText();
|
virtual std::string GetEncodedText();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using ScriptTextRef = ScriptObjectRef<ScriptText>;
|
using ScriptTextRef = ScriptObjectRef<ScriptText>;
|
||||||
|
Loading…
Reference in New Issue
Block a user