|
|
|
@ -26,6 +26,8 @@
|
|
|
|
|
#include "signal_func.h"
|
|
|
|
|
#include "core/backup_type.hpp"
|
|
|
|
|
#include "object_base.h"
|
|
|
|
|
#include "newgrf_text.h"
|
|
|
|
|
#include "string_func.h"
|
|
|
|
|
|
|
|
|
|
#include "table/strings.h"
|
|
|
|
|
|
|
|
|
@ -735,7 +737,9 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
|
|
|
|
|
* test and execution have yielded the same result,
|
|
|
|
|
* i.e. cost and error state are the same. */
|
|
|
|
|
if (!test_and_exec_can_differ) {
|
|
|
|
|
assert(res.GetCost() == res2.GetCost() && res.Failed() == res2.Failed()); // sanity check
|
|
|
|
|
assert_msg(res.GetCost() == res2.GetCost() && res.Failed() == res2.Failed(),
|
|
|
|
|
"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
|
|
|
|
|
} else if (res2.Failed()) {
|
|
|
|
|
return_dcpi(res2);
|
|
|
|
|
}
|
|
|
|
@ -803,3 +807,34 @@ void CommandCost::UseTextRefStack(const GRFFile *grffile, uint num_registers)
|
|
|
|
|
textref_stack[i] = _temp_store.GetValue(0x100 + i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *CommandCost::AllocSummaryMessage(StringID cmd_msg) const
|
|
|
|
|
{
|
|
|
|
|
char buf[DRAW_STRING_BUFFER];
|
|
|
|
|
this->WriteSummaryMessage(buf, lastof(buf), cmd_msg);
|
|
|
|
|
return stredup(buf, lastof(buf));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int CommandCost::WriteSummaryMessage(char *buf, char *last, StringID cmd_msg) const
|
|
|
|
|
{
|
|
|
|
|
if (this->Succeeded()) {
|
|
|
|
|
return seprintf(buf, last, "Success: cost: " OTTD_PRINTF64, (int64) this->GetCost());
|
|
|
|
|
} else {
|
|
|
|
|
if (this->textref_stack_size > 0) StartTextRefStackUsage(this->textref_stack_grffile, this->textref_stack_size, textref_stack);
|
|
|
|
|
|
|
|
|
|
char *b = buf;
|
|
|
|
|
b += seprintf(b, last, "Failed: cost: " OTTD_PRINTF64, (int64) this->GetCost());
|
|
|
|
|
if (cmd_msg != 0) {
|
|
|
|
|
b += seprintf(b, last, " ");
|
|
|
|
|
b = GetString(b, cmd_msg, last);
|
|
|
|
|
}
|
|
|
|
|
if (this->message != INVALID_STRING_ID) {
|
|
|
|
|
b += seprintf(b, last, " ");
|
|
|
|
|
b = GetString(b, this->message, last);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this->textref_stack_size > 0) StopTextRefStackUsage();
|
|
|
|
|
|
|
|
|
|
return b - buf;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|