marked some functions for inlining

This commit is contained in:
Mark de Wever 2007-02-16 21:19:41 +00:00
parent 52735b00d8
commit d75611e919
2 changed files with 55 additions and 187 deletions

View file

@ -156,11 +156,6 @@ display::~display()
prune_chat_messages(true);
}
Uint32 display::rgb(Uint8 red, Uint8 green, Uint8 blue)
{
return 0xFF000000 | (red << 16) | (green << 8) | blue;
}
void display::new_turn()
{
const time_of_day& tod = status_.get_time_of_day();
@ -216,26 +211,6 @@ void display::adjust_colours(int r, int g, int b)
image::set_colour_adjustment(tod.red+r,tod.green+g,tod.blue+b);
}
int display::x() const { return screen_.getx(); }
int display::mapx() const { return x() - 140; }
int display::y() const { return screen_.gety(); }
const SDL_Rect& display::map_area() const
{
return theme_.main_map_location(screen_area());
}
const SDL_Rect& display::minimap_area() const
{
return theme_.mini_map_location(screen_area());
}
const SDL_Rect& display::unit_image_area() const
{
return theme_.unit_image_location(screen_area());
}
SDL_Rect display::screen_area() const
{
const SDL_Rect res = {0,0,x(),y()};
@ -398,16 +373,6 @@ gamemap::location display::pixel_position_to_hex(int x, int y, gamemap::location
return res;
}
int display::get_location_x(const gamemap::location& loc) const
{
return map_area().x + loc.x*hex_width() - xpos_;
}
int display::get_location_y(const gamemap::location& loc) const
{
return map_area().y + loc.y*zoom_ - ypos_ + (is_odd(loc.x) ? zoom_/2 : 0);
}
void display::get_rect_hex_bounds(SDL_Rect rect, gamemap::location &topleft, gamemap::location &bottomright) const
{
const int tile_width = hex_width();
@ -432,11 +397,6 @@ void display::get_rect_hex_bounds(SDL_Rect rect, gamemap::location &topleft, gam
}
}
void display::get_visible_hex_bounds(gamemap::location &topleft, gamemap::location &bottomright) const
{
get_rect_hex_bounds(map_area(), topleft, bottomright);
}
gamemap::location display::minimap_location_on(int x, int y)
{
const SDL_Rect rect = minimap_area();
@ -527,16 +487,6 @@ void display::invalidate_locations_in_rect(SDL_Rect r)
}
}
int display::hex_size() const
{
return zoom_;
}
int display::hex_width() const
{
return (zoom_*3)/4;
}
double display::zoom(int amount)
{
int new_zoom = zoom_ + amount;
@ -566,11 +516,6 @@ double display::zoom(int amount)
return double(zoom_)/double(DefaultZoom);
}
void display::default_zoom()
{
zoom(DefaultZoom - zoom_);
}
void display::screenshot()
{
std::string datadir = get_screenshot_dir();
@ -594,6 +539,11 @@ void display::screenshot()
SDL_SaveBMP(screen_.getSurface().get(), name.c_str());
}
void display::default_zoom()
{
zoom(DefaultZoom - zoom_);
}
void display::scroll_to_tile(int x, int y, SCROLL_TYPE scroll_type, bool check_fogged)
{
if(screen_.update_locked() || (check_fogged && fogged(x,y))) {
@ -2179,11 +2129,6 @@ void display::invalidate_all()
update_rect(map_area());
}
void display::invalidate_unit()
{
invalidateUnit_ = true;
}
void display::invalidate_animations()
{
new_animation_frame();
@ -2221,10 +2166,6 @@ void display::invalidate_animations()
}
void display::invalidate_theme(){
panelsDrawn_ = false;
}
void display::recalculate_minimap()
{
if(minimap_ != NULL) {
@ -2234,12 +2175,6 @@ void display::recalculate_minimap()
redraw_minimap();
// remove unit after invalidating...
}
void display::redraw_minimap()
{
redrawMinimap_ = true;
}
void display::place_temporary_unit(unit &u, const gamemap::location& loc)
{
temp_unit_ = &u;
@ -2259,12 +2194,6 @@ void display::remove_temporary_unit()
// remove unit after invalidating...
temp_unit_ = NULL;
}
void display::invalidate_game_status()
{
invalidateGameStatus_ = true;
}
void display::add_overlay(const gamemap::location& loc, const std::string& img, const std::string& halo)
{
const int halo_handle = halo::add(get_location_x(loc)+hex_size()/2,get_location_y(loc)+hex_size()/2,halo);
@ -2336,11 +2265,6 @@ bool display::turbo() const
return res || screen_.faked();
}
void display::set_turbo(bool turbo)
{
turbo_ = turbo;
}
double display::turbo_speed() const
{
if (turbo_ || keys_[SDLK_LSHIFT] || keys_[SDLK_RSHIFT])
@ -2375,11 +2299,6 @@ void display::delay(unsigned int milliseconds) const
SDL_Delay(milliseconds);
}
void display::set_grid(bool grid)
{
grid_ = grid;
}
// timestring() returns the current date as a string.
// Uses preferences::clock_format() for formatting.
std::string timestring ( void )
@ -2406,50 +2325,8 @@ void display::debug_highlight(const gamemap::location& loc, fixed_t amount)
debugHighlights_[loc] += amount;
}
void display::clear_debug_highlights()
gui::button* display::find_button(const std::string& id)
{
debugHighlights_.clear();
}
bool display::shrouded(int x, int y) const
{
if(team_valid()) {
return teams_[currentTeam_].shrouded(x,y);
} else {
return false;
}
}
bool display::fogged(int x, int y) const
{
if(team_valid()) {
return teams_[currentTeam_].fogged(x,y);
} else {
return false;
}
}
bool display::team_valid() const
{
return currentTeam_ < teams_.size();
}
size_t display::viewing_team() const
{
return currentTeam_;
}
size_t display::playing_team() const
{
return activeTeam_;
}
theme& display::get_theme()
{
return theme_;
}
gui::button* display::find_button(const std::string& id){
for (size_t i = 0; i < buttons_.size(); ++i) {
if(buttons_[i].id() == id) {
return &buttons_[i];
@ -2515,23 +2392,14 @@ void display::create_buttons()
}
}
gui::button::TYPE display::string_to_button_type(std::string type){
gui::button::TYPE display::string_to_button_type(std::string type)
{
gui::button::TYPE res = gui::button::TYPE_PRESS;
if (type == "checkbox") { res = gui::button::TYPE_CHECK; }
else if (type == "image") { res = gui::button::TYPE_IMAGE; }
return res;
}
void display::add_observer(const std::string& name)
{
observers_.insert(name);
}
void display::remove_observer(const std::string& name)
{
observers_.erase(name);
}
namespace {
const int chat_message_border = 5;
const int chat_message_x = 10;
@ -2623,11 +2491,6 @@ void display::add_chat_message(const std::string& speaker, int side, const std::
}
}
void display::clear_chat_messages()
{
prune_chat_messages(true);
}
void display::prune_chat_messages(bool remove_all)
{
const unsigned int message_ttl = remove_all ? 0 : 1200000;
@ -2660,15 +2523,8 @@ void display::set_diagnostic(const std::string& msg)
}
}
void display::rebuild_terrain(const gamemap::location &loc) {
builder_.rebuild_terrain(loc);
}
void display::rebuild_all() {
builder_.rebuild_all();
}
void display::add_highlighted_loc(const gamemap::location &hex) {
void display::add_highlighted_loc(const gamemap::location &hex)
{
// Only invalidate and insert if this is a new addition, for
// efficiency.
if (highlighted_locations_.find(hex) == highlighted_locations_.end()) {
@ -2677,7 +2533,8 @@ void display::add_highlighted_loc(const gamemap::location &hex) {
}
}
void display::clear_highlighted_locs() {
void display::clear_highlighted_locs()
{
for (std::set<gamemap::location>::const_iterator it = highlighted_locations_.begin();
it != highlighted_locations_.end(); it++) {
invalidate(*it);
@ -2685,7 +2542,8 @@ void display::clear_highlighted_locs() {
highlighted_locations_.clear();
}
void display::remove_highlighted_loc(const gamemap::location &hex) {
void display::remove_highlighted_loc(const gamemap::location &hex)
{
std::set<gamemap::location>::iterator it = highlighted_locations_.find(hex);
// Only invalidate and remove if the hex was found, for efficiency.
if (it != highlighted_locations_.end()) {

View file

@ -59,7 +59,8 @@ public:
const config& cfg, const config& level);
~display();
static Uint32 rgb(Uint8 red, Uint8 green, Uint8 blue);
static Uint32 rgb(Uint8 red, Uint8 green, Uint8 blue)
{ return 0xFF000000 | (red << 16) | (green << 8) | blue; }
//new_turn should be called on every new turn, to update
//lighting settings.
@ -86,11 +87,11 @@ public:
//function which returns the size of a hex in pixels
//(from top tip to bottom tip or left edge to right edge)
int hex_size() const;
int hex_size() const { return zoom_; }
//function which returns the width of a pixel, up to where the next hex starts
//(i.e. not entirely from tip to tip -- use hex_size() to get the distance from tip to tip)
int hex_width() const;
int hex_width() const { return (zoom_*3)/4; }
enum SCROLL_TYPE { SCROLL, WARP, ONSCREEN };
@ -121,13 +122,16 @@ public:
//the dimensions of the display. x and y are width/height. mapx is the
//width of the portion of the display which shows the game area. Between
//mapx and x is the sidebar region.
int x() const;
int mapx() const;
int y() const;
int x() const { return screen_.getx(); }
int mapx() const { return x() - 140; }
int y() const { return screen_.gety(); }
const SDL_Rect& map_area() const;
const SDL_Rect& minimap_area() const;
const SDL_Rect& unit_image_area() const;
const SDL_Rect& map_area() const
{ return theme_.main_map_location(screen_area()); }
const SDL_Rect& minimap_area() const
{ return theme_.mini_map_location(screen_area()); }
const SDL_Rect& unit_image_area() const
{ return theme_.unit_image_location(screen_area()); }
SDL_Rect screen_area() const;
@ -183,11 +187,14 @@ public:
void set_route(const paths::route* route);
//functions to get the on-screen positions of hexes.
int get_location_x(const gamemap::location& loc) const;
int get_location_y(const gamemap::location& loc) const;
int get_location_x(const gamemap::location& loc) const
{ return map_area().x + loc.x*hex_width() - xpos_; }
int get_location_y(const gamemap::location& loc) const
{ return map_area().y + loc.y*zoom_ - ypos_ + (is_odd(loc.x) ? zoom_/2 : 0); }
//returns the locations of 2 hexes that bind the visible area of the map.
void get_visible_hex_bounds(gamemap::location &topleft, gamemap::location &bottomright) const;
void get_visible_hex_bounds(gamemap::location &topleft, gamemap::location &bottomright) const
{ get_rect_hex_bounds(map_area(), topleft, bottomright); }
//function to remove a footstep from a specific location
void remove_footstep(const gamemap::location& loc);
@ -255,18 +262,18 @@ public:
void invalidate(const gamemap::location& loc);
//function to invalidate the game status displayed on the sidebar.
void invalidate_game_status();
const gamestatus &get_game_status() {return status_;};
void invalidate_game_status() { invalidateGameStatus_ = true; }
const gamestatus &get_game_status() { return status_; }
//function to invalidate that unit status displayed on the sidebar.
void invalidate_unit();
void invalidate_unit() { invalidateUnit_ = true; }
//function to invalidate animated terrains which may have changed.
void invalidate_animations();
//function to invalidate controls and panels when changed after
//they have been drawn initially. Useful for dynamic theme modification.
void invalidate_theme();
void invalidate_theme() { panelsDrawn_ = false; }
//function to schedule the minimap for recalculation. Useful if any
//terrain in the map has changed.
@ -274,7 +281,7 @@ public:
//function to schedule the minimap to be redrawn. Useful if units
//have moved about on the map
void redraw_minimap();
void redraw_minimap() { redrawMinimap_ = true; }
//temporarily place a unit on map (moving: can overlap others)
void place_temporary_unit(unit &u, const gamemap::location& loc);
@ -324,7 +331,7 @@ public:
//functions to set/get whether 'turbo' mode is on. When turbo mode is on,
//everything moves much faster.
bool turbo() const;
void set_turbo(bool turbo);
void set_turbo(const bool turbo) { turbo_ = turbo; }
double turbo_speed() const;
void set_turbo_speed(const double speed);
@ -335,26 +342,28 @@ public:
//function which determines whether a grid should be overlayed on the
//game board to more clearly show where hexes are.
void set_grid(bool grid);
void set_grid(const bool grid) { grid_ = grid; }
//a debug highlight draws a cross on a tile to emphasize something there.
//it is used in debug mode, typically to show AI plans.
static void debug_highlight(const gamemap::location& loc, fixed_t amount);
static void clear_debug_highlights();
static void clear_debug_highlights() { debugHighlights_.clear(); }
//function which returns true if location (x,y) is covered in shroud.
bool shrouded(int x, int y) const;
bool shrouded(int x, int y) const
{ return team_valid() ? teams_[currentTeam_].shrouded(x,y) : false; }
bool fogged(int x, int y) const;
bool fogged(int x, int y) const
{ return team_valid() ? teams_[currentTeam_].fogged(x,y) : false; }
//the viewing team is the team currently viewing the game. The playing team
//is the team whose turn it is
size_t viewing_team() const;
size_t playing_team() const;
bool team_valid() const;
size_t viewing_team() const { return currentTeam_; }
size_t playing_team() const { return activeTeam_; }
bool team_valid() const { return currentTeam_ < teams_.size(); }
const std::string current_team_name() const;
theme& get_theme();
theme& get_theme() { return theme_; }
gui::button* find_button(const std::string& id);
const theme::menu* menu_pressed();
@ -362,8 +371,8 @@ public:
//finds the menu which has a given item in it, and enables or disables it.
void enable_menu(const std::string& item, bool enable);
void add_observer(const std::string& name);
void remove_observer(const std::string& name);
void add_observer(const std::string& name) { observers_.insert(name); }
void remove_observer(const std::string& name) { observers_.erase(name); }
const std::set<std::string>& observers() const { return observers_; }
map_labels& labels() { return map_labels_; }
@ -373,7 +382,7 @@ public:
enum MESSAGE_TYPE { MESSAGE_PUBLIC, MESSAGE_PRIVATE };
void add_chat_message(const std::string& speaker, int side, const std::string& msg, MESSAGE_TYPE type);
void clear_chat_messages();
void clear_chat_messages() { prune_chat_messages(true); }
//function to draw the image of a unit at a certain location
//x,y: pixel location on screen to draw the unit
@ -393,9 +402,10 @@ public:
surface ellipse_front=surface(NULL));
//rebuild the dynamic terrain at the given location.
void rebuild_terrain(const gamemap::location &location);
void rebuild_terrain(const gamemap::location &loc)
{ builder_.rebuild_terrain(loc); }
//rebuild all dynamic terrain.
void rebuild_all();
void rebuild_all() { builder_.rebuild_all(); }
//Add a location to highlight. Note that this has nothing to do with
//selecting hexes, it is pure highlighting. These hexes will be