MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / InternalPostResult

Method InternalPostResult

src/command.cpp:238–258  ·  view source on GitHub ↗

* Process result of executing a command, possibly displaying any error to the player. * @param res Command result. * @param tile Tile of command execution. * @param estimate_only Is this just cost estimation? * @param only_sending Was the command only sent to network? * @param err_message Message prefix to show on error. * @param my_cmd Is the command from this client? */

Source from the content-addressed store, hash-verified

236 * @param my_cmd Is the command from this client?
237 */
238void CommandHelperBase::InternalPostResult(CommandCost &res, TileIndex tile, bool estimate_only, bool only_sending, StringID err_message, bool my_cmd)
239{
240 int x = TileX(tile) * TILE_SIZE;
241 int y = TileY(tile) * TILE_SIZE;
242
243 if (res.Failed()) {
244 /* Only show the error when it's for us. */
245 if (estimate_only || (IsLocalCompany() && err_message != 0 && my_cmd)) {
246 ShowErrorMessage(GetEncodedString(err_message), x, y, res);
247 }
248 } else if (estimate_only) {
249 ShowEstimatedCostOrIncome(res.GetCost(), x, y);
250 } else if (!only_sending && tile != 0 && IsLocalCompany() && _game_mode != GM_EDITOR) {
251 /* Only show the cost animation when we did actually
252 * execute the command, i.e. we're not sending it to
253 * the server, when it has cost the local company
254 * something. Furthermore in the editor there is no
255 * concept of cost, so don't show it there either. */
256 ShowCostOrIncomeAnimation(x, y, GetSlopePixelZ(x, y), res.GetCost());
257 }
258}
259
260/** Helper to make a desync log for a command. */
261void CommandHelperBase::LogCommandExecution(Commands cmd, StringID err_message, const CommandDataBuffer &args, bool failed)

Callers

nothing calls this directly

Calls 10

TileXFunction · 0.85
TileYFunction · 0.85
IsLocalCompanyFunction · 0.85
ShowErrorMessageFunction · 0.85
GetSlopePixelZFunction · 0.85
FailedMethod · 0.80
GetEncodedStringFunction · 0.70
GetCostMethod · 0.45

Tested by

no test coverage detected