本文整理汇总了C++中CommandCost::SetGlobalErrorMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ CommandCost::SetGlobalErrorMessage方法的具体用法?C++ CommandCost::SetGlobalErrorMessage怎么用?C++ CommandCost::SetGlobalErrorMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandCost
的用法示例。
在下文中一共展示了CommandCost::SetGlobalErrorMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoCommand
/*!
* This function executes a given command with the parameters from the #CommandProc parameter list.
* Depending on the flags parameter it execute or test a command.
*
* @param tile The tile to apply the command on (for the #CommandProc)
* @param p1 Additional data for the command (for the #CommandProc)
* @param p2 Additional data for the command (for the #CommandProc)
* @param flags Flags for the command and how to execute the command
* @param cmd The command-id to execute (a value of the CMD_* enums)
* @param text The text to pass
* @see CommandProc
* @return the cost
*/
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const char *text)
{
CommandCost res;
/* Do not even think about executing out-of-bounds tile-commands */
if (tile != 0 && (tile >= MapSize() || (!IsValidTile(tile) && (flags & DC_ALL_TILES) == 0))) return CMD_ERROR;
/* Chop of any CMD_MSG or other flags; we don't need those here */
CommandProc *proc = _command_proc_table[cmd & CMD_ID_MASK].proc;
if (_docommand_recursive == 0) _error_message = INVALID_STRING_ID;
_docommand_recursive++;
/* only execute the test call if it's toplevel, or we're not execing. */
if (_docommand_recursive == 1 || !(flags & DC_EXEC) ) {
SetTownRatingTestMode(true);
res = proc(tile, flags & ~DC_EXEC, p1, p2, text);
SetTownRatingTestMode(false);
if (CmdFailed(res)) {
res.SetGlobalErrorMessage();
goto error;
}
if (_docommand_recursive == 1 &&
!(flags & DC_QUERY_COST) &&
!(flags & DC_BANKRUPT) &&
res.GetCost() != 0 &&
!CheckCompanyHasMoney(res)) {
goto error;
}
if (!(flags & DC_EXEC)) {
_docommand_recursive--;
return res;
}
}
/* Execute the command here. All cost-relevant functions set the expenses type
* themselves to the cost object at some point */
res = proc(tile, flags, p1, p2, text);
if (CmdFailed(res)) {
res.SetGlobalErrorMessage();
error:
_docommand_recursive--;
return CMD_ERROR;
}
/* if toplevel, subtract the money. */
if (--_docommand_recursive == 0 && !(flags & DC_BANKRUPT)) {
SubtractMoneyFromCompany(res);
}
return res;
}