CommandCost: Change AllocSummaryMessage to std::string SummaryMessage

This commit is contained in:
Jonathan G Rennison
2023-08-20 21:15:14 +01:00
parent b0538a00e0
commit 2b44d3302e
2 changed files with 5 additions and 5 deletions

View File

@@ -1233,7 +1233,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint64 p3,
if (!test_and_exec_can_differ) { if (!test_and_exec_can_differ) {
assert_msg(res.GetCost() == res2.GetCost() && res.Failed() == res2.Failed(), assert_msg(res.GetCost() == res2.GetCost() && res.Failed() == res2.Failed(),
"Command: cmd: 0x%X (%s), Test: %s, Exec: %s", cmd, GetCommandName(cmd), "Command: cmd: 0x%X (%s), Test: %s, Exec: %s", cmd, GetCommandName(cmd),
res.AllocSummaryMessage(GB(cmd, 16, 16)), res2.AllocSummaryMessage(GB(cmd, 16, 16))); // sanity check res.SummaryMessage(GB(cmd, 16, 16)).c_str(), res2.SummaryMessage(GB(cmd, 16, 16)).c_str()); // sanity check
} else if (res2.Failed()) { } else if (res2.Failed()) {
return_dcpi(res2); return_dcpi(res2);
} }
@@ -1318,11 +1318,11 @@ void CommandCost::UseTextRefStack(const GRFFile *grffile, uint num_registers)
} }
} }
char *CommandCost::AllocSummaryMessage(StringID cmd_msg) const std::string CommandCost::SummaryMessage(StringID cmd_msg) const
{ {
char buf[DRAW_STRING_BUFFER]; char buf[DRAW_STRING_BUFFER];
this->WriteSummaryMessage(buf, lastof(buf), cmd_msg); this->WriteSummaryMessage(buf, lastof(buf), cmd_msg);
return stredup(buf, lastof(buf)); return buf;
} }
int CommandCost::WriteSummaryMessage(char *buf, char *last, StringID cmd_msg) const int CommandCost::WriteSummaryMessage(char *buf, char *last, StringID cmd_msg) const

View File

@@ -218,9 +218,9 @@ public:
/** /**
* @param cmd_msg optional failure string as passed to DoCommand * @param cmd_msg optional failure string as passed to DoCommand
* @return an allocated string summarising the command result * @return a string summarising the command result
*/ */
char *AllocSummaryMessage(StringID cmd_msg = 0) const; std::string SummaryMessage(StringID cmd_msg = 0) const;
/** /**
* Write a string summarising the command result * Write a string summarising the command result