mail[Wesnoth-commits] r29130 - in /trunk: changelog src/game_display.cpp src/game_display.hpp src/game_events.cpp src/playsingle_controller.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by soliton . de on August 31, 2008 - 03:19:
Author: soliton
Date: Sun Aug 31 03:02:55 2008
New Revision: 29130

URL: http://svn.gna.org/viewcvs/wesnoth?rev=29130&view=rev
Log:
* properly applied patch #1100 by Broodkiller (implements bug #11817: Allow 
[item]s to be visible only to specified teams)
  * fixed overlay initialization order
  * fixed some whitespace issues
  * added a changelog entry

Modified:
    trunk/changelog
    trunk/src/game_display.cpp
    trunk/src/game_display.hpp
    trunk/src/game_events.cpp
    trunk/src/playsingle_controller.cpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=29130&r1=29129&r2=29130&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Sun Aug 31 03:02:55 2008
@@ -34,6 +34,8 @@
    * prevent some negative/nonsense values in direct WML unit modifications
    * Renamed the advanceto key in [unit_type] to advances_to in order to be
      consistent with its own and [unit]'s internals.
+   * implemented FR #11817: Allow [item]s to be visible only to specified 
teams
+     (patch #1100 by Broodkiller)
  * Networking
    * removed null termination character from end of packet send by wesnoth
  * Miscellaneous and bug fixes:

Modified: trunk/src/game_display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_display.cpp?rev=29130&r1=29129&r2=29130&view=diff
==============================================================================
--- trunk/src/game_display.cpp (original)
+++ trunk/src/game_display.cpp Sun Aug 31 03:02:55 2008
@@ -338,8 +338,12 @@
                typedef overlay_map::const_iterator Itor;
                std::pair<Itor,Itor> overlays = overlays_.equal_range(loc);
                for( ; overlays.first != overlays.second; ++overlays.first) {
-                       drawing_buffer_add(LAYER_TERRAIN_BG, drawing_order, 
tblit(xpos, ypos,
-                               
image::get_image(overlays.first->second.image,image_type)));
+                       if (overlays.first->second.team_name == "" ||
+                       
overlays.first->second.team_name.find(teams_[playing_team()].team_name()) != 
std::string::npos)
+                       {
+                               drawing_buffer_add(LAYER_TERRAIN_BG, 
drawing_order, tblit(xpos, ypos,
+                                       
image::get_image(overlays.first->second.image,image_type)));
+                       }
                }
                // village-control flags.
                drawing_buffer_add(LAYER_TERRAIN_BG, drawing_order, 
tblit(xpos, ypos, get_flag(loc)));          
@@ -962,12 +966,12 @@
        set_attack_indicator(gamemap::location::null_location, 
gamemap::location::null_location);
 }
 
-void game_display::add_overlay(const gamemap::location& loc, const 
std::string& img, const std::string& halo)
+void game_display::add_overlay(const gamemap::location& loc, const 
std::string& img, const std::string& halo,const std::string& team_name)
 {
        const int halo_handle = halo::add(get_location_x(loc) + hex_size() / 
2,
                        get_location_y(loc) + hex_size() / 2, halo, loc);
 
-       const overlay item(img,halo,halo_handle);
+       const overlay item(img, halo, halo_handle, team_name);
        overlays_.insert(overlay_map::value_type(loc,item));
 }
 
@@ -1010,6 +1014,20 @@
                i->first.write(item);
                item["image"] = i->second.image;
                item["halo"] = i->second.halo;
+               item["team_name"] = i->second.team_name;
+       }
+}
+
+void game_display::parse_team_overlays()
+{
+       for (game_display::overlay_map::const_iterator overlay = 
overlays_.begin(); overlay != overlays_.end(); ++overlay) {
+
+               if (overlay->second.team_name != "" &&
+               
bool(overlay->second.team_name.find(teams_[playing_team()].team_name())+1) !=
+               bool(overlay->second.team_name.find(teams_[playing_team()-1 > 
-1 ? playing_team()-1 : teams_.size()-1].team_name())+1))
+               {
+                       invalidate(overlay->first);
+               }
        }
 }
 

Modified: trunk/src/game_display.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_display.hpp?rev=29130&r1=29129&r2=29130&view=diff
==============================================================================
--- trunk/src/game_display.hpp (original)
+++ trunk/src/game_display.hpp Sun Aug 31 03:02:55 2008
@@ -171,7 +171,7 @@
        //! Functions to add and remove overlays from locations.
        //! An overlay is an image that is displayed on top of the tile.
        //! One tile may have multiple overlays.
-       void add_overlay(const gamemap::location& loc, const std::string& 
image, const std::string& halo="");
+       void add_overlay(const gamemap::location& loc, const std::string& 
image, const std::string& halo="", const std::string& team_name="");
        //! remove_overlay will remove all overlays on a tile.
        void remove_overlay(const gamemap::location& loc);
        //! remove_single_overlay will remove a single overlay from a tile
@@ -180,6 +180,9 @@
        //! Function to serialize overlay data.
        void write_overlays(config& cfg) const;
 
+       //! Check the overlay_map for proper team-specific overlays
+       //! to be displayed/hidden
+       void parse_team_overlays();
 
        // Functions used in the editor:
 
@@ -278,10 +281,11 @@
 
        struct overlay {
                overlay(const std::string& img, const std::string& halo_img,
-                       int handle) : image(img), halo(halo_img),
-                               halo_handle(handle) {}
+                       int handle, const std::string& overlay_team_name) : 
image(img), halo(halo_img),
+                               team_name(overlay_team_name), 
halo_handle(handle) {}
                std::string image;
                std::string halo;
+               std::string team_name;
                int halo_handle;
        };
 

Modified: trunk/src/game_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=29130&r1=29129&r2=29130&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Sun Aug 31 03:02:55 2008
@@ -1564,9 +1564,10 @@
                gamemap::location loc = cfg_to_loc(cfg);
                std::string img = cfg["image"];
                std::string halo = cfg["halo"];
+               std::string team_name = cfg["team_name"];
                assert(state_of_game != NULL);
                if(!img.empty() || !halo.empty()) {
-                       (screen)->add_overlay(loc,img,halo);
+                       (screen)->add_overlay(loc, img, halo, team_name);
                        (screen)->invalidate(loc);
                        (screen)->draw();
                }

Modified: trunk/src/playsingle_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playsingle_controller.cpp?rev=29130&r1=29129&r2=29130&view=diff
==============================================================================
--- trunk/src/playsingle_controller.cpp (original)
+++ trunk/src/playsingle_controller.cpp Sun Aug 31 03:02:55 2008
@@ -253,7 +253,7 @@
        // Find a list of 'items' (i.e. overlays) on the level, and add them
        const config::child_list& overlays = level_.get_children("item");
        for(config::child_list::const_iterator overlay = overlays.begin(); 
overlay != overlays.end(); ++overlay) {
-               
gui_->add_overlay(gamemap::location(**overlay,game_events::get_state_of_game()),(**overlay)["image"],
 (**overlay)["halo"]);
+               gui_->add_overlay(gamemap::location(**overlay, 
game_events::get_state_of_game()), (**overlay)["image"], (**overlay)["halo"], 
(**overlay)["team_name"]);
        }
 
        victory_conditions::set_victory_when_enemies_defeated(
@@ -563,6 +563,9 @@
 
 void playsingle_controller::play_side(const unsigned int team_index, bool 
save)
 {
+       //check for team-specific items in the scenario
+       gui_->parse_team_overlays();
+
        //flag used when we fallback from ai and give temporarily control to 
human
        bool temporary_human = false;
        do {




Related Messages


Powered by MHonArc, Updated Sun Aug 31 12:02:50 2008