diff --git a/src/Utils.cpp b/src/Utils.cpp index 1ce3ec3..ec0445f 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -9,29 +9,29 @@ void Utils::flood_fill(vector< vector >* map, int start_x, int start_y, int int width = map->at(0).size(); int height = map->size(); - //The scanline floodfill algorithm using our own stack routines, faster if(old_color == new_color) return; stack.clear(); int curr_x; bool traverse_above, traverse_below; coord_t current_coord = {start_x, start_y}; - + + // Push the start position on stack stack.push_back(current_coord); while(!stack.empty()) { - cout << "Stack length: " << stack.size() << endl; current_coord = stack.back(); stack.pop_back(); curr_x = current_coord.x; - + + // Start "from left" in memory so that all writes occour in order while(curr_x >= 0 && map->at(current_coord.y).at(curr_x) == old_color) curr_x--; - + curr_x++; traverse_above = traverse_below = false; - + while(curr_x < width && map->at(current_coord.y).at(curr_x) == old_color ) { map->at(current_coord.y).at(curr_x) = new_color; @@ -47,7 +47,6 @@ void Utils::flood_fill(vector< vector >* map, int start_x, int start_y, int } if(!traverse_below && current_coord.y < height - 1 && map->at(current_coord.y + 1).at(curr_x) == old_color) { - cout << "In span below" << endl; stack.push_back({curr_x, current_coord.y + 1}); traverse_below = true; }