mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-15 17:25:32 +00:00
Fixed a bug in the multi-hex tiling code...
...causing severe memory corruption and failure to invalidate old terrains when terrains were rebuilt.
This commit is contained in:
parent
e3c775bb9e
commit
20940bde4b
@ -16,6 +16,19 @@
|
||||
#include "util.hpp"
|
||||
#include "log.hpp"
|
||||
|
||||
void terrain_builder::tile::clear()
|
||||
{
|
||||
flags.clear();
|
||||
images_foreground.clear();
|
||||
images_background.clear();
|
||||
}
|
||||
|
||||
void terrain_builder::tilemap::reset()
|
||||
{
|
||||
for(std::vector<tile>::iterator it = map_.begin(); it != map_.end(); ++it)
|
||||
it->clear();
|
||||
}
|
||||
|
||||
terrain_builder::terrain_builder(const config& cfg, const gamemap& gmap) :
|
||||
map_(gmap), tile_map_(gmap.x(), gmap.y())
|
||||
{
|
||||
@ -41,7 +54,7 @@ const std::vector<image::locator> *terrain_builder::get_terrain_at(const gamemap
|
||||
|
||||
void terrain_builder::rebuild_terrain(const gamemap::location &loc)
|
||||
{
|
||||
tile_map_.clear();
|
||||
tile_map_.reset();
|
||||
terrain_by_type_.clear();
|
||||
|
||||
// For now, rebuild the whole map on each rebuilt_terrain. This is highly slow and
|
||||
|
@ -68,6 +68,8 @@ private:
|
||||
std::set<std::string> flags;
|
||||
std::vector<image::locator> images_foreground;
|
||||
std::vector<image::locator> images_background;
|
||||
|
||||
void clear();
|
||||
};
|
||||
|
||||
struct tilemap
|
||||
@ -76,7 +78,7 @@ private:
|
||||
|
||||
tile &operator[](const gamemap::location &loc) { return map_[(loc.x+1) + (loc.y+1)*(x_+2)]; }
|
||||
const tile &operator[] (const gamemap::location &loc) const { return map_[(loc.x+1) + (loc.y+1)*(x_+2)]; }
|
||||
void clear() { map_.clear(); }
|
||||
void reset();
|
||||
|
||||
std::vector<tile> map_;
|
||||
int x_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user