From 02cb1dc2c4a7a513f89c7b8c3e72d7864a9f63b8 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Thu, 13 Oct 2022 20:41:50 +0100 Subject: [PATCH] CommandCost: Add a tile auxiliary field --- src/command.cpp | 10 ++++++++++ src/command_type.h | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/src/command.cpp b/src/command.cpp index aa74231970..870f4a0467 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -1274,3 +1274,13 @@ int CommandCost::WriteSummaryMessage(char *buf, char *last, StringID cmd_msg) co return b - buf; } } + +void CommandCost::SetTile(TileIndex tile) +{ + if (tile == this->GetTile()) return; + + if (!this->aux_data) { + this->aux_data.reset(new CommandCostAuxliaryData()); + } + this->aux_data->tile = tile; +} diff --git a/src/command_type.h b/src/command_type.h index 79b03e5c3b..59a1c9da10 100644 --- a/src/command_type.h +++ b/src/command_type.h @@ -32,6 +32,7 @@ class CommandCost { uint32 textref_stack[16] = {}; const GRFFile *textref_stack_grffile = nullptr; ///< NewGRF providing the #TextRefStack content. uint textref_stack_size = 0; ///< Number of uint32 values to put on the #TextRefStack for the error message. + TileIndex tile = INVALID_TILE; }; std::unique_ptr aux_data; @@ -225,6 +226,13 @@ public: res.success = false; return res; } + + TileIndex GetTile() const + { + return this->aux_data != nullptr ? this->aux_data->tile : INVALID_TILE; + } + + void SetTile(TileIndex tile); }; /**