Skip to content

Commit 9cea5e0

Browse files
committed
Code style improvement in OverlayWidget class
1 parent 2a5b7ab commit 9cea5e0

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/editor/overlay_widget.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ namespace {
4646

4747
const int snap_grid_sizes[4] = {4, 8, 16, 32};
4848

49+
const int MAX_FILL_STACK_SIZE = 1000000;
50+
4951
bool is_position_inside_tilemap(const TileMap* tilemap, const Vector& pos)
5052
{
5153
return pos.x >= 0 && pos.y >= 0 &&
@@ -387,21 +389,18 @@ EditorOverlayWidget::fill()
387389
return;
388390
}
389391

390-
std::vector<Vector> pos_stack;
391-
pos_stack.clear();
392-
pos_stack.push_back(m_hovered_tile);
392+
std::vector<Vector> pos_stack = { m_hovered_tile };
393393

394-
// Passing recursively trough all tiles to be replaced...
394+
// Passing recursively through all tiles to be replaced...
395395
while (pos_stack.size())
396396
{
397-
398-
if (pos_stack.size() > 1000000)
397+
if (pos_stack.size() > MAX_FILL_STACK_SIZE)
399398
{
400399
log_warning << "More than 1'000'000 tiles in stack to fill, STOP" << std::endl;
401400
return;
402401
}
403402

404-
Vector pos = pos_stack[pos_stack.size() - 1];
403+
Vector pos = pos_stack.back();
405404
Vector tpos = pos - m_hovered_tile;
406405

407406
// Tests for being inside tilemap:

0 commit comments

Comments
 (0)