Minor cleanup in the dynamic rebuilding of terrain.
This commit is contained in:
parent
ce362b34b7
commit
5a9fee57a7
4 changed files with 9 additions and 32 deletions
|
@ -2160,9 +2160,6 @@ void display::prune_chat_messages(bool remove_all)
|
|||
}
|
||||
|
||||
|
||||
void display::rebuild_terrains(const std::vector<gamemap::location> &locations) {
|
||||
for (std::vector<gamemap::location>::const_iterator it = locations.begin();
|
||||
it != locations.end(); it++) {
|
||||
builder_.rebuild_terrain(*it);
|
||||
}
|
||||
void display::rebuild_terrain(const gamemap::location &loc) {
|
||||
builder_.rebuild_terrain(loc);
|
||||
}
|
||||
|
|
|
@ -306,8 +306,8 @@ public:
|
|||
bool upside_down=false,double alpha=1.0, Uint32 blendto=0, double submerged=0.0,
|
||||
SDL_Surface* ellipse_back=NULL, SDL_Surface* ellipse_front=NULL);
|
||||
|
||||
//rebuild the dynamic terrain at the given locations.
|
||||
void rebuild_terrains(const std::vector<gamemap::location> &locations);
|
||||
//rebuild the dynamic terrain at the given location.
|
||||
void rebuild_terrain(const gamemap::location &location);
|
||||
|
||||
private:
|
||||
display(const display&);
|
||||
|
|
|
@ -394,7 +394,6 @@ void map_editor::undo() {
|
|||
--num_operations_since_save_;
|
||||
map_undo_action action = undo_stack_.back();
|
||||
map_.set_terrain(action.location,action.old_terrain);
|
||||
dirty_positions_.push_back(action.location);
|
||||
undo_stack_.pop_back();
|
||||
redo_stack_.push_back(action);
|
||||
if(redo_stack_.size() > undo_limit)
|
||||
|
@ -408,7 +407,6 @@ void map_editor::redo() {
|
|||
++num_operations_since_save_;
|
||||
map_undo_action action = redo_stack_.back();
|
||||
map_.set_terrain(action.location,action.new_terrain);
|
||||
dirty_positions_.push_back(action.location);
|
||||
redo_stack_.pop_back();
|
||||
undo_stack_.push_back(action);
|
||||
if(undo_stack_.size() > undo_limit)
|
||||
|
@ -419,7 +417,6 @@ void map_editor::redo() {
|
|||
|
||||
void map_editor::set_starting_position(const int player, const gamemap::location loc) {
|
||||
if(map_.on_board(loc)) {
|
||||
dirty_positions_.push_back(loc);
|
||||
map_.set_terrain(loc, gamemap::CASTLE);
|
||||
// This operation is currently not undoable, so we need to make sure
|
||||
// that save is always asked for after it is performed.
|
||||
|
@ -473,7 +470,6 @@ void map_editor::draw_terrain(const gamemap::TERRAIN terrain,
|
|||
if(undo_stack_.size() > undo_limit)
|
||||
undo_stack_.pop_front();
|
||||
map_.set_terrain(hex, terrain);
|
||||
dirty_positions_.push_back(hex);
|
||||
invalidate_adjacent(hex);
|
||||
}
|
||||
|
||||
|
@ -492,6 +488,7 @@ void map_editor::invalidate_adjacent(const gamemap::location hex) {
|
|||
invalidate_adjacent(locs[i]);
|
||||
}
|
||||
}
|
||||
gui_.rebuild_terrain(locs[i]);
|
||||
gui_.invalidate(locs[i]);
|
||||
}
|
||||
minimap_dirty_ = true;
|
||||
|
@ -602,21 +599,6 @@ void map_editor::execute_command(const hotkey::HOTKEY_COMMAND command) {
|
|||
}
|
||||
}
|
||||
|
||||
void map_editor::rebuild_dirty_terrains() {
|
||||
std::vector<gamemap::location> including_adjacent;
|
||||
for (std::vector<gamemap::location>::const_iterator it = dirty_positions_.begin();
|
||||
it != dirty_positions_.end(); it++) {
|
||||
gamemap::location locs[7];
|
||||
locs[0] = *it;
|
||||
get_adjacent_tiles(*it,locs+1);
|
||||
for(int i = 0; i != 7; ++i) {
|
||||
including_adjacent.push_back(locs[i]);
|
||||
}
|
||||
gui_.rebuild_terrains(including_adjacent);
|
||||
}
|
||||
dirty_positions_.clear();
|
||||
}
|
||||
|
||||
void map_editor::main_loop() {
|
||||
const double scroll_speed = preferences::scroll_speed();
|
||||
unsigned int counter = 0;
|
||||
|
@ -663,7 +645,6 @@ void map_editor::main_loop() {
|
|||
middle_button_down(mousex, mousey);
|
||||
}
|
||||
|
||||
rebuild_dirty_terrains();
|
||||
gui_.draw(false);
|
||||
palette_.draw();
|
||||
//if(drawterrainpalette(gui_, tstart_, selected_terrain_, map_, size_specs_) == false)
|
||||
|
|
|
@ -165,8 +165,6 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
void map_editor::rebuild_dirty_terrains();
|
||||
|
||||
/// Called in every iteration when the left mouse button is held
|
||||
/// down. Note that this differs from a click.
|
||||
void left_button_down(const int mousex, const int mousey);
|
||||
|
@ -194,7 +192,7 @@ private:
|
|||
const int yloc, const bool context_menu=false);
|
||||
|
||||
/// Pass the command onto the hotkey handling system. Quit requests
|
||||
/// are intercepted because the editor do not want the default
|
||||
/// are intercepted because the editor does not want the default
|
||||
/// behavior of those.
|
||||
void execute_command(const hotkey::HOTKEY_COMMAND command);
|
||||
|
||||
|
@ -203,7 +201,9 @@ private:
|
|||
void draw_terrain(const gamemap::TERRAIN terrain,
|
||||
const gamemap::location hex);
|
||||
|
||||
// Invalidate the given hex and all the adjacent ones.
|
||||
/// Invalidate the given hex and all the adjacent ones. Assume the
|
||||
/// hex has changed, so rebuild the dynamic terrain at the hex and
|
||||
/// the adjacent hexes.
|
||||
void invalidate_adjacent(const gamemap::location hex);
|
||||
|
||||
/// Shows dialog to create new map.
|
||||
|
@ -236,7 +236,6 @@ private:
|
|||
// scheduled.
|
||||
bool minimap_dirty_;
|
||||
terrain_palette palette_;
|
||||
std::vector<gamemap::location> dirty_positions_;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue