diff options
-rw-r--r-- | src/engine/data/bounds.cpp | 5 | ||||
-rw-r--r-- | src/engine/data/bounds.hpp | 2 | ||||
-rw-r--r-- | src/game/game.cpp | 11 |
3 files changed, 16 insertions, 2 deletions
diff --git a/src/engine/data/bounds.cpp b/src/engine/data/bounds.cpp index bee98ba..ad67ad2 100644 --- a/src/engine/data/bounds.cpp +++ b/src/engine/data/bounds.cpp @@ -85,3 +85,8 @@ auto Bounds::operator-(const Bounds &rhs) const noexcept -> Bounds return new_bounds; } + +auto Bounds::operator>(const Bounds &rhs) const noexcept -> bool +{ + return (_width > rhs._width) || _height > rhs._height; +} diff --git a/src/engine/data/bounds.hpp b/src/engine/data/bounds.hpp index 2375d77..1a775b7 100644 --- a/src/engine/data/bounds.hpp +++ b/src/engine/data/bounds.hpp @@ -45,6 +45,8 @@ public: auto operator-(const Bounds &rhs) const noexcept -> Bounds; + auto operator>(const Bounds &rhs) const noexcept -> bool; + private: Value _width = 0U; Value _height = 0U; diff --git a/src/game/game.cpp b/src/game/game.cpp index 05b02fd..9835fc5 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -613,12 +613,19 @@ void Game::_open_rle_file(CommandInfo::Options options) noexcept return; } + auto scene_matrix = _scene->get_matrix(); + + if (rle_matrix->get_size() > scene_matrix->get_size()) + { + _show_command_error("Error: The pattern in the RLE file is too large for the " + "current terminal size"); + return; + } + _return_to_normal_mode(); const auto previous_pos = _cursor_controller->where(); - auto scene_matrix = _scene->get_matrix(); - for (auto row : *rle_matrix) { for (auto &col : row) |