[[Editor optimization]]

* Minor speed optimizations (TODO: test whether these are actually
  worth something)

* Fixed editor where nothing was displayed until terrains were rebuilt.
This commit is contained in:
Philippe Plantier 2004-08-15 19:42:44 +00:00
parent 72e8619a03
commit 906845dc4d
4 changed files with 21 additions and 16 deletions

View file

@ -72,7 +72,7 @@ public:
bool animation_finished() const;
int get_animation_time() const;
int get_frame_time() const;
const T& get_current_frame() const;
inline const T& get_current_frame() const;
const T& get_base_frame() const;
private:
@ -324,10 +324,10 @@ const T& animated<T,T_void_value>::get_current_frame() const
{
if(no_current_frame_ == true)
return void_value_;
if(!frames_[current_frame_].has_value)
const frame& cur = frames_[current_frame_];
if(!cur.has_value)
return void_value_;
return frames_[current_frame_].value;
return cur.value;
}
template<typename T, typename T_void_value>

View file

@ -179,15 +179,19 @@ bool terrain_builder::update_animation(const gamemap::location &loc)
return changed;
}
// TODO: rename this function
void terrain_builder::rebuild_terrain(const gamemap::location &loc)
{
if (tile_map_.on_map(loc)) {
tile& btile = tile_map_[loc];
btile.clear();
// btile.images.clear();
btile.images_foreground.clear();
btile.images_background.clear();
const std::string filename =
map_.get_terrain_info(map_.get_terrain(loc)).default_image();
animated<image::locator> img_loc(filename);
btile.images_foreground.push_back(img_loc);
animated<image::locator> img_loc("terrain/" + filename + ".png");
img_loc.start_animation(0, animated<image::locator>::INFINITE_CYCLES);
btile.images_background.push_back(img_loc);
}
}

View file

@ -66,14 +66,6 @@ void free_sdl_surface::operator()(SDL_Surface* surf) const
{
}
int surface::sdl_add_ref(SDL_Surface* surf)
{
if(surf != NULL) {
return surf->refcount++;
} else {
return 0;
}
}
surface make_neutral_surface(surface surf)
{

View file

@ -45,7 +45,7 @@ struct free_sdl_surface {
struct surface
{
private:
int sdl_add_ref(SDL_Surface* surf);
inline int sdl_add_ref(SDL_Surface* surf);
typedef util::scoped_resource<SDL_Surface*,free_sdl_surface> scoped_sdl_surface;
public:
surface() : surface_(NULL)
@ -84,6 +84,15 @@ private:
scoped_sdl_surface surface_;
};
int surface::sdl_add_ref(SDL_Surface* surf)
{
if(surf != NULL) {
return surf->refcount++;
} else {
return 0;
}
}
bool operator<(const surface& a, const surface& b);
surface make_neutral_surface(surface surf);