From 65865114fd70946d467443e820fcdac033ea7a58 Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Sun, 4 Feb 2007 14:17:33 +0000 Subject: [PATCH] marked several functions for inlining --- src/map.cpp | 69 ----------------------------------------------------- src/map.hpp | 43 +++++++++++++++++++++------------ 2 files changed, 28 insertions(+), 84 deletions(-) diff --git a/src/map.cpp b/src/map.cpp index 24461454b22..6cb12171e7f 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -82,48 +82,6 @@ const t_translation::t_list& gamemap::underlying_union_terrain(t_translation::t_ return i->second.union_type(); } } - -bool gamemap::is_village(t_translation::t_letter terrain) const -{ - return get_terrain_info(terrain).is_village(); -} - -int gamemap::gives_healing(t_translation::t_letter terrain) const -{ - return get_terrain_info(terrain).gives_healing(); -} - -bool gamemap::is_castle(t_translation::t_letter terrain) const -{ - return get_terrain_info(terrain).is_castle(); -} - -bool gamemap::is_keep(t_translation::t_letter terrain) const -{ - return get_terrain_info(terrain).is_keep(); -} - -bool gamemap::is_village(const gamemap::location& loc) const -{ - return on_board(loc) && is_village(get_terrain(loc)); -} - -int gamemap::gives_healing(const gamemap::location& loc) const -{ - if (!on_board(loc)) - return 0; - return gives_healing(get_terrain(loc)); -} - -bool gamemap::is_castle(const gamemap::location& loc) const -{ - return on_board(loc) && is_castle(get_terrain(loc)); -} - -bool gamemap::is_keep(const gamemap::location& loc) const -{ - return on_board(loc) && is_keep(get_terrain(loc)); -} bool gamemap::filter_location(const gamemap::location &loc,const config & /*con*/) const { //need to fill this in @@ -472,14 +430,6 @@ void gamemap::overlay(const gamemap& m, const config& rules_cfg, const int xpos, } } -int gamemap::x() const { return tiles_.size(); } -int gamemap::y() const { return tiles_.empty() ? 0 : tiles_.front().size(); } - -const t_translation::t_list& gamemap::operator[](int index) const -{ - return tiles_[index]; -} - t_translation::t_letter gamemap::get_terrain(const gamemap::location& loc) const { if(on_board(loc)) @@ -539,11 +489,6 @@ int gamemap::num_valid_starting_positions() const return res; } -int gamemap::num_starting_positions() const -{ - return sizeof(startingPositions_)/sizeof(*startingPositions_); -} - int gamemap::is_starting_position(const gamemap::location& loc) const { const gamemap::location* const beg = startingPositions_+1; @@ -572,10 +517,6 @@ const terrain_type& gamemap::get_terrain_info(const t_translation::t_letter terr return default_terrain; } -const terrain_type& gamemap::get_terrain_info(const gamemap::location &loc) const -{ - return get_terrain_info(get_terrain(loc)); -} bool gamemap::terrain_matches_filter(const gamemap::location& loc, const config& cfg, const gamestatus& game_status, const unit_map& units, const bool flat_tod) const { @@ -685,11 +626,6 @@ bool gamemap::terrain_matches_filter(const gamemap::location& loc, const config& return true; } -const t_translation::t_list& gamemap::get_terrain_list() const -{ - return terrainList_; -} - void gamemap::set_terrain(const gamemap::location& loc, const t_translation::t_letter terrain) { if(!on_board(loc)) @@ -762,8 +698,3 @@ const std::map& gamemap::get_weighted_terrain_f return terrainFrequencyCache_; } - -void gamemap::remove_from_border_cache(const location &loc) { - borderCache_.erase(loc); -} - diff --git a/src/map.hpp b/src/map.hpp index 7cc8cdff6ff..8681c8692e0 100644 --- a/src/map.hpp +++ b/src/map.hpp @@ -99,15 +99,23 @@ public: const t_translation::t_list& underlying_union_terrain(const location& loc) const { return underlying_union_terrain(get_terrain(loc)); } - bool is_village(t_translation::t_letter terrain) const; - int gives_healing(t_translation::t_letter terrain) const; - bool is_castle(t_translation::t_letter terrain) const; - bool is_keep(t_translation::t_letter terrain) const; + bool is_village(t_translation::t_letter terrain) const + { return get_terrain_info(terrain).is_village(); } + int gives_healing(t_translation::t_letter terrain) const + { return get_terrain_info(terrain).gives_healing(); } + bool is_castle(t_translation::t_letter terrain) const + { return get_terrain_info(terrain).is_castle(); } + bool is_keep(t_translation::t_letter terrain) const + { return get_terrain_info(terrain).is_keep(); } - bool is_village(const location& loc) const; - int gives_healing(const location& loc) const; - bool is_castle(const location& loc) const; - bool is_keep(const location& loc) const; + bool is_village(const location& loc) const + { return on_board(loc) && is_village(get_terrain(loc)); } + int gives_healing(const location& loc) const + { return on_board(loc) ? gives_healing(get_terrain(loc)) : 0; } + bool is_castle(const location& loc) const + { return on_board(loc) && is_castle(get_terrain(loc)); } + bool is_keep(const location& loc) const + { return on_board(loc) && is_keep(get_terrain(loc)); } //function to filter whether a location matches a set of criteria bool filter_location(const location &loc,const config &con) const; @@ -125,11 +133,12 @@ public: void overlay(const gamemap& m, const config& rules, int x=0, int y=0); //dimensions of the map. - int x() const; - int y() const; + int x() const { return tiles_.size(); } + int y() const { return tiles_.empty() ? 0 : tiles_.front().size(); } //allows lookup of terrain at a particular location. - const t_translation::t_list& operator[](int index) const; + const t_translation::t_list& operator[](int index) const + { return tiles_[index]; } //looks up terrain at a particular location. Hexes off the map //may be looked up, and their 'emulated' terrain will also be returned. @@ -168,13 +177,15 @@ public: const terrain_type& get_terrain_info(const t_translation::t_letter terrain) const; //shortcut to get_terrain_info(get_terrain(loc)) - const terrain_type& get_terrain_info(const location &loc) const; + const terrain_type& get_terrain_info(const location &loc) const + { return get_terrain_info(get_terrain(loc)); } // bool terrain_matches_filter(const location& loc, const config& cfg, const gamestatus& game_status, const unit_map& units, const bool flat_tod=false) const; //gets the list of terrains - const t_translation::t_list& get_terrain_list() const; + const t_translation::t_list& get_terrain_list() const + { return terrainList_; } //clobbers over the terrain at location 'loc', with the given terrain void set_terrain(const location& loc, const t_translation::t_letter terrain); @@ -185,7 +196,8 @@ public: //remove the cached border terrain at loc. Needed by the editor //to make tiles at the border update correctly when drawing //other tiles. - void remove_from_border_cache(const location &loc); + void remove_from_border_cache(const location &loc) + { borderCache_.erase(loc); } //the size of the starting positions array //the positions themselves are numbered from @@ -197,7 +209,8 @@ protected: location startingPositions_[STARTING_POSITIONS]; private: - int num_starting_positions() const; + int num_starting_positions() const + { return sizeof(startingPositions_)/sizeof(*startingPositions_); } t_translation::t_list terrainList_; std::map letterToTerrain_;