Author: mordante
Date: Sun May 27 01:13:07 2007
New Revision: 17879

URL: http://svn.gna.org/viewcvs/wesnoth?rev=17879&view=rev
Log:
display has a lot of functions with x and y parameters where it's not clear 
what these are.
started to change functions which get a map location to use gamemap::location
this commit does fogged() and shrouded(), more will follow

Modified:
    trunk/src/display.cpp
    trunk/src/display.hpp
    trunk/src/game_events.cpp
    trunk/src/halo.cpp
    trunk/src/map_label.cpp
    trunk/src/menu_events.cpp
    trunk/src/mouse_events.cpp
    trunk/src/play_controller.cpp
    trunk/src/playsingle_controller.cpp
    trunk/src/soundsource.cpp
    trunk/src/unit.cpp
    trunk/src/unit_display.cpp

Modified: trunk/src/display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.cpp?rev=17879&r1=17878&r2=17879&view=diff
==============================================================================
--- trunk/src/display.cpp (original)
+++ trunk/src/display.cpp Sun May 27 01:13:07 2007
@@ -216,7 +216,7 @@
 
 void display::select_hex(gamemap::location hex)
 {
-       if(team_valid() && teams_[currentTeam_].fogged(hex.x,hex.y)) {
+       if(fogged(hex)) {
                return;
        }
 
@@ -534,11 +534,11 @@
 
 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))) {
+       const gamemap::location loc(x,y);
+
+       if(screen_.update_locked() || (check_fogged && fogged(loc))) {
                return;
        }
-
-       const gamemap::location loc(x,y);
 
        if(map_.on_board(loc) == false) {
                return;
@@ -1247,7 +1247,9 @@
                                        if(report_num == reports::TIME_OF_DAY 
&& img != NULL) {
                                                time_of_day tod = 
timeofday_at(status_,units_,mouseoverHex_,map_);
                                                // don't show illuminated time 
on fogged/shrouded tiles
-                                               if 
(teams_[viewing_team()].fogged(mouseoverHex_.x,mouseoverHex_.y) || 
teams_[viewing_team()].shrouded(mouseoverHex_.x,mouseoverHex_.y)) {
+                                               if 
(teams_[viewing_team()].fogged(mouseoverHex_.x, mouseoverHex_.y) || 
+                                                               
teams_[viewing_team()].shrouded(mouseoverHex_.x, mouseoverHex_.y)) {
+
                                                        tod = 
status_.get_time_of_day(false,mouseoverHex_);
                                                }
                                                if(tod.bonus_modified > 0) {
@@ -1310,7 +1312,7 @@
        int map_w = map_.x(), map_h = map_.y();
 
        for(unit_map::const_iterator u = units_.begin(); u != units_.end(); 
++u) {
-               if(fogged(u->first.x,u->first.y) ||
+               if(fogged(u->first) ||
                                
(teams_[currentTeam_].is_enemy(u->second.side()) &&
                                u->second.invisible(u->first,units_,teams_))) {
                        continue;
@@ -1450,7 +1452,7 @@
 
        surface const dst(screen_.getSurface());
 
-       const bool is_shrouded = shrouded(loc.x, loc.y);
+       const bool is_shrouded = shrouded(loc);
        t_translation::t_letter terrain = t_translation::VOID_TERRAIN;
 
        if(!is_shrouded) {
@@ -1521,7 +1523,7 @@
                
draw_terrain_on_tile(loc.x,loc.y,image_type,ADJACENT_FOREGROUND);
        }
 
-       if(fogged(loc.x,loc.y) && shrouded(loc.x,loc.y) == false) {
+       if(fogged(loc) && shrouded(loc) == false) {
                const surface fog_surface(image::get_image("terrain/fog.png"));
                if(fog_surface != NULL) {
                        SDL_Rect dstrect = { xpos, ypos, 0, 0 };
@@ -1529,7 +1531,7 @@
                }
        }
 
-       if(!shrouded(loc.x,loc.y)) {
+       if(!shrouded(loc)) {
                draw_terrain_on_tile(loc.x,loc.y,image_type,ADJACENT_FOGSHROUD);
        }
 
@@ -1789,9 +1791,9 @@
                { t_translation::FOGGED, t_translation::VOID_TERRAIN, 
t_translation::NONE_TERRAIN };
 
        for(int i = 0; i != 6; ++i) {
-               if(shrouded(adjacent[i].x,adjacent[i].y)) {
+               if(shrouded(adjacent[i])) {
                        tiles[i] = t_translation::VOID_TERRAIN;
-               } else if(!fogged(loc.x,loc.y) && 
fogged(adjacent[i].x,adjacent[i].y)) {
+               } else if(!fogged(loc) && fogged(adjacent[i])) {
                        tiles[i] = t_translation::FOGGED;
                } else {
                        tiles[i] = t_translation::NONE_TERRAIN; 
@@ -1911,7 +1913,7 @@
        const gamemap::location loc(x,y);
 
        for(size_t i = 0; i != teams_.size(); ++i) {
-               if(teams_[i].owns_village(loc) && (!fogged(x,y) || 
!shrouded(x,y) && !teams_[currentTeam_].is_enemy(i+1))) {
+               if(teams_[i].owns_village(loc) && (!fogged(loc)) || 
!shrouded(loc) && !teams_[currentTeam_].is_enemy(i+1)) {
                        flags_[i].update_last_draw_time();
                        return image::get_image(flags_[i].get_current_frame());
                }
@@ -2042,7 +2044,7 @@
 void display::float_label(const gamemap::location& loc, const std::string& 
text,
                                                  int red, int green, int blue)
 {
-       if(preferences::show_floating_labels() == false || fogged(loc.x,loc.y)) 
{
+       if(preferences::show_floating_labels() == false || fogged(loc)) {
                return;
        }
 
@@ -2208,13 +2210,13 @@
        
        for(int x = topleft.x; x <= bottomright.x; ++x) {
                for(int y = topleft.y; y <= bottomright.y; ++y) {
-                       if (!shrouded(x,y)) {
-                               gamemap::location loc(x,y);
+                       const gamemap::location loc(x,y);
+                       if (!shrouded(loc)) {
                                if (builder_.update_animation(loc)) {
                                        invalidate(loc);
                                } else if (map_.is_village(loc)) {
                                        const int owner = 
player_teams::village_owner(loc);
-                                       if (owner >= 0 && 
flags_[owner].need_update() && (!fogged(x,y) || 
!teams_[currentTeam_].is_enemy(owner+1)))
+                                       if (owner >= 0 && 
flags_[owner].need_update() && (!fogged(loc)) || 
!teams_[currentTeam_].is_enemy(owner+1))
                                                invalidate(loc);
                                }
                        }
@@ -2373,10 +2375,10 @@
 
 //NOTE : Hex outside the map are displayed as shrouded.
 //So they are updated and the shroud-transition soften the edge of the map
-bool display::shrouded(int x, int y) const
-{
-       if (x >= -1 && y >= -1 && x <= map_.x() && y <= map_.y()) {
-               return team_valid() ? teams_[currentTeam_].shrouded(x,y) : 
false;
+bool display::shrouded(const gamemap::location& loc) const
+{
+       if (loc.x >= -1 && loc.y >= -1 && loc.x <= map_.x() && loc.y <= 
map_.y()) {
+               return team_valid() ? teams_[currentTeam_].shrouded(loc.x, 
loc.y) : false;
        } else {
                return true;
        }

Modified: trunk/src/display.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.hpp?rev=17879&r1=17878&r2=17879&view=diff
==============================================================================
--- trunk/src/display.hpp (original)
+++ trunk/src/display.hpp Sun May 27 01:13:07 2007
@@ -340,10 +340,10 @@
        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 fogged(int x, int y) const
-               { return team_valid() ? teams_[currentTeam_].fogged(x,y) : 
false; }
+       bool shrouded(const gamemap::location& loc) const;
+
+       bool fogged(const gamemap::location& loc) const
+               { return team_valid() ? teams_[currentTeam_].fogged(loc.x, 
loc.y) : false; }
 
        //the viewing team is the team currently viewing the game. The playing 
team
        //is the team whose turn it is

Modified: trunk/src/game_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=17879&r1=17878&r2=17879&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Sun May 27 01:13:07 2007
@@ -1338,7 +1338,7 @@
 
                if(game_map->on_board(loc)) {
                        loc = find_vacant_tile(*game_map,*units,loc);
-                       const bool show = screen != NULL && 
!screen->fogged(loc.x,loc.y);
+                       const bool show = screen != NULL && 
!screen->fogged(loc);
                        const bool animate = show && cfg["animate"] != "";
 
                        units->erase(loc);
@@ -2044,7 +2044,7 @@
                }
 
                //we have found a unit that matches the filter
-               if(u != units->end() && ! 
screen->fogged(u->first.x,u->first.y)) {
+               if(u != units->end() && ! screen->fogged(u->first)) {
                        screen->highlight_hex(u->first);
                        screen->scroll_to_tile(u->first.x,u->first.y);
 

Modified: trunk/src/halo.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/halo.cpp?rev=17879&r1=17878&r2=17879&view=diff
==============================================================================
--- trunk/src/halo.cpp (original)
+++ trunk/src/halo.cpp Sun May 27 01:13:07 2007
@@ -125,7 +125,7 @@
                return false;
        }
        
-       if(loc_.x != -1 && loc_.y != -1 && disp->shrouded(loc_.x, loc_.y)) {
+       if(loc_.x != -1 && loc_.y != -1 && disp->shrouded(loc_)) {
                return false;
        }
 

Modified: trunk/src/map_label.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/map_label.cpp?rev=17879&r1=17878&r2=17879&view=diff
==============================================================================
--- trunk/src/map_label.cpp (original)
+++ trunk/src/map_label.cpp Sun May 27 01:13:07 2007
@@ -32,9 +32,9 @@
 //itself is visible, but the tile below is obscured, the bottom half of the
 //tile will still be shrouded, and the label being drawn looks weird
 static bool is_shrouded(const display& disp, const gamemap::location& loc)
-       {
-               return disp.shrouded(loc.x,loc.y) || 
disp.shrouded(loc.x,loc.y+1);
-       }
+{
+       return disp.shrouded(loc) || 
disp.shrouded(gamemap::location(loc.x,loc.y+1));
+}
 
 map_labels::map_labels(const display& disp, 
                                           const gamemap& map, 

Modified: trunk/src/menu_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.cpp?rev=17879&r1=17878&r2=17879&view=diff
==============================================================================
--- trunk/src/menu_events.cpp (original)
+++ trunk/src/menu_events.cpp Sun May 27 01:13:07 2007
@@ -1169,7 +1169,7 @@
                for(unit_map::iterator u = units_.begin(); u != units_.end(); 
++u) {
                        bool invisible = u->second.invisible(u->first, units_, 
teams_);
 
-                       if(teams_[team_num - 1].is_enemy(u->second.side()) && 
!gui_->fogged(u->first.x,u->first.y) && !u->second.incapacitated() && 
!invisible) {
+                       if(teams_[team_num - 1].is_enemy(u->second.side()) && 
!gui_->fogged(u->first) && !u->second.incapacitated() && !invisible) {
                                const unit_movement_resetter 
move_reset(u->second);
                                const bool teleports = 
u->second.get_ability_bool("teleport",u->first);
                                unit_map units(u->first, u->second);
@@ -1719,7 +1719,7 @@
                                if(std::search(label->text().begin(), 
label->text().end(),
                                                last_search_.begin(), 
last_search_.end(),
                                                chars_equal_insensitive) != 
label->text().end()) {
-                                       found = !gui_->shrouded(loc.x, loc.y);
+                                       found = !gui_->shrouded(loc);
                                }
                        }
                        //Search unit name
@@ -1729,7 +1729,7 @@
                                if(std::search(name.begin(), name.end(),
                                                last_search_.begin(), 
last_search_.end(),
                                                chars_equal_insensitive) != 
name.end()) {
-                                       found = !gui_->fogged(loc.x, loc.y);
+                                       found = !gui_->fogged(loc);
                                }
                        }
                        if(loc == start)

Modified: trunk/src/mouse_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/mouse_events.cpp?rev=17879&r1=17878&r2=17879&view=diff
==============================================================================
--- trunk/src/mouse_events.cpp (original)
+++ trunk/src/mouse_events.cpp Sun May 27 01:13:07 2007
@@ -821,7 +821,7 @@
 
                unit_map::iterator un = mouseover_unit;
 
-               if(un != units_.end() && current_paths_.routes.empty() && 
!(*gui_).fogged(un->first.x,un->first.y)) {
+               if(un != units_.end() && current_paths_.routes.empty() && 
!(*gui_).fogged(un->first)) {
                        if (un->second.side() != team_num_) {
                                //unit under cursor is not on our team, 
highlight reach
                                unit_movement_resetter move_reset(un->second);
@@ -1183,7 +1183,7 @@
 
                const unit_map::iterator it = find_unit(hex);
 
-               if(it != units_.end() && it->second.side() == team_num_ && 
!gui_->fogged(it->first.x,it->first.y)) {
+               if(it != units_.end() && it->second.side() == team_num_ && 
!gui_->fogged(it->first)) {
                        const bool teleport = 
it->second.get_ability_bool("teleport",it->first);
                        current_paths_ = 
paths(map_,status_,gameinfo_,units_,hex,teams_,
                                                                   
false,teleport,viewing_team(),path_turns_);
@@ -1420,7 +1420,7 @@
 
 bool mouse_handler::unit_in_cycle(unit_map::const_iterator it)
 {
-       if(it->second.side() == team_num_ && 
unit_can_move(it->first,units_,map_,teams_) && it->second.user_end_turn() == 
false && !gui_->fogged(it->first.x,it->first.y)) {
+       if(it->second.side() == team_num_ && 
unit_can_move(it->first,units_,map_,teams_) && it->second.user_end_turn() == 
false && !gui_->fogged(it->first)) {
                bool is_enemy = 
current_team().is_enemy(int(gui_->viewing_team()+1));
                return is_enemy == false || 
it->second.invisible(it->first,units_,teams_) == false;
        }
@@ -1470,7 +1470,7 @@
 
 inline void mouse_handler::select_unit(const unit_map::const_iterator &it,
                                                                           
const unit_map::const_iterator &itx) {
-       if (it != itx && !gui_->fogged(it->first.x,it->first.y)) {
+       if (it != itx && !gui_->fogged(it->first)) {
                const bool teleport = 
it->second.get_ability_bool("teleport",it->first);
                current_paths_ = 
paths(map_,status_,gameinfo_,units_,it->first,teams_,false,teleport,viewing_team(),path_turns_);
                gui_->highlight_reach(current_paths_);

Modified: trunk/src/play_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/play_controller.cpp?rev=17879&r1=17878&r2=17879&view=diff
==============================================================================
--- trunk/src/play_controller.cpp (original)
+++ trunk/src/play_controller.cpp Sun May 27 01:13:07 2007
@@ -437,7 +437,7 @@
 
        //See if any enemies are visible
        for(unit_map::const_iterator u = units_.begin(); u != units_.end(); ++u)
-               if(current_team().is_enemy(u->second.side()) && 
!gui_->fogged(u->first.x,u->first.y))
+               if(current_team().is_enemy(u->second.side()) && 
!gui_->fogged(u->first))
                        return true;
 
        return false;

Modified: trunk/src/playsingle_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playsingle_controller.cpp?rev=17879&r1=17878&r2=17879&view=diff
==============================================================================
--- trunk/src/playsingle_controller.cpp (original)
+++ trunk/src/playsingle_controller.cpp Sun May 27 01:13:07 2007
@@ -591,7 +591,7 @@
                        res = menu_handler_.has_team();
                case hotkey::HOTKEY_LABEL_TERRAIN:
                        res = res && !events::commands_disabled && 
map_.on_board(mouse_handler_.get_last_hex())
-                               && 
!gui_->shrouded(mouse_handler_.get_last_hex().x, 
mouse_handler_.get_last_hex().y)
+                               && 
!gui_->shrouded(mouse_handler_.get_last_hex())
                                && !is_observer();
                        break;
 

Modified: trunk/src/soundsource.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/soundsource.cpp?rev=17879&r1=17878&r2=17879&view=diff
==============================================================================
--- trunk/src/soundsource.cpp (original)
+++ trunk/src/soundsource.cpp Sun May 27 01:13:07 2007
@@ -167,8 +167,8 @@
                int locx = disp.get_location_x(*i);
                int locy = disp.get_location_y(*i);
 
-               if(disp.outside_area(area, locx, locy) || disp.shrouded((*i).x, 
(*i).y) 
-                       || (!_play_fogged && disp.fogged((*i).x, (*i).y)))
+               if(disp.outside_area(area, locx, locy) || disp.shrouded(*i) 
+                       || (!_play_fogged && disp.fogged(*i)))
                                continue;
                else {
                        _visible = true;

Modified: trunk/src/unit.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=17879&r1=17878&r2=17879&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Sun May 27 01:13:07 2007
@@ -1644,7 +1644,7 @@
 void unit::redraw_unit(display& disp,gamemap::location hex)
 {
        const gamemap & map = disp.get_map();
-       if(hidden_ || disp.fogged(hex.x,hex.y) ||
+       if(hidden_ || disp.fogged(hex) ||
                        (invisible(hex,disp.get_units(),disp.get_teams()) &&
                        disp.get_teams()[disp.viewing_team()].is_enemy(side())) 
){
 

Modified: trunk/src/unit_display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_display.cpp?rev=17879&r1=17878&r2=17879&view=diff
==============================================================================
--- trunk/src/unit_display.cpp (original)
+++ trunk/src/unit_display.cpp Sun May 27 01:13:07 2007
@@ -33,12 +33,12 @@
 static void teleport_unit_between( const gamemap::location& a, const 
gamemap::location& b, unit& temp_unit)
 {
        display* disp = display::get_singleton();
-       if(!disp || disp->update_locked() || disp->fogged(a.x,a.y) && 
disp->fogged(b.x,b.y)) {
+       if(!disp || disp->update_locked() || disp->fogged(a) && 
disp->fogged(b)) {
                return;
        }
 
        temp_unit.set_teleporting(*disp,a);
-       if (!disp->fogged(a.x, a.y)) { // teleport
+       if (!disp->fogged(a)) { // teleport
                disp->scroll_to_tile(a.x,a.y,display::ONSCREEN);
                while(!temp_unit.get_animation()->animation_finished()  && 
temp_unit.get_animation()->get_animation_time() < 0) {
                        disp->invalidate(a);
@@ -48,7 +48,7 @@
                        disp->delay(10);
                }
        }
-       if (!disp->fogged(b.x, b.y)) { // teleport
+       if (!disp->fogged(b)) { // teleport
                temp_unit.restart_animation(*disp,0);
                disp->scroll_to_tile(b.x,b.y,display::ONSCREEN);
                while(!temp_unit.get_animation()->animation_finished()) {
@@ -67,7 +67,7 @@
 static void move_unit_between( const gamemap& map, const gamemap::location& a, 
const gamemap::location& b, unit& temp_unit)
 {
        display* disp = display::get_singleton();
-       if(!disp || disp->update_locked() || disp->fogged(a.x,a.y) && 
disp->fogged(b.x,b.y)) {
+       if(!disp || disp->update_locked() || disp->fogged(a) && 
disp->fogged(b)) {
                return;
        }
 
@@ -180,7 +180,7 @@
 const attack_type* attack,const attack_type* secondary_attack, unit* winner)
 {
        display* disp = display::get_singleton();
-       if(!disp ||disp->update_locked() || disp->fogged(loc.x,loc.y) || 
preferences::show_combat() == false) {
+       if(!disp ||disp->update_locked() || disp->fogged(loc) || 
preferences::show_combat() == false) {
                return;
        }
                const std::string& die_sound = loser.die_sound();
@@ -222,7 +222,7 @@
 {
        display* disp = display::get_singleton();
        if(!disp) return;
-       const bool hide = disp->update_locked() || disp->fogged(a.x,a.y) && 
disp->fogged(b.x,b.y)
+       const bool hide = disp->update_locked() || disp->fogged(a) && 
disp->fogged(b)
                || preferences::show_combat() == false ;
 
        unit_map& units = disp->get_units();
@@ -329,7 +329,7 @@
                missile_frame_halo = halo::NO_HALO;
                if(animation_time > missile_animation.get_begin_time() &&
                                animation_time < 
missile_animation.get_end_time() &&
-                               (!disp->fogged(b.x,b.y) || 
!disp->fogged(a.x,a.y))) {
+                               (!disp->fogged(b) || !disp->fogged(a))) {
                        const int posx = int(pos*xdst + (1.0-pos)*xsrc);
                        const int posy = int(pos*ydst + (1.0-pos)*ysrc);
 
@@ -405,7 +405,7 @@
        display* disp = display::get_singleton();
        if(!disp) return;
        unit_map& units = disp->get_units();
-       const bool hide = disp->update_locked() || disp->fogged(a.x,a.y) && 
disp->fogged(b.x,b.y)
+       const bool hide = disp->update_locked() || disp->fogged(a) && 
disp->fogged(b)
                          || preferences::show_combat() == false;
 
        if(!hide) {
@@ -526,7 +526,7 @@
 void unit_recruited(gamemap::location& loc)
 {
        display* disp = display::get_singleton();
-       if(!disp || disp->update_locked() ||disp->fogged(loc.x,loc.y)) return;
+       if(!disp || disp->update_locked() ||disp->fogged(loc)) return;
        unit_map::iterator u = disp->get_units().find(loc);
        if(u == disp->get_units().end()) return;
 
@@ -548,7 +548,7 @@
 void unit_healing(unit& healed_p,gamemap::location& healed_loc, 
std::vector<unit_map::iterator> healers, int healing)
 {
        display* disp = display::get_singleton();
-       if(!disp || disp->update_locked() || 
disp->fogged(healed_loc.x,healed_loc.y)) return;
+       if(!disp || disp->update_locked() || disp->fogged(healed_loc)) return;
        if(healing==0) return;
        // This is all the pretty stuff.
        int start_time = INT_MAX;


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to