wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src builder.cpp builder.hpp config.cpp ...


From: Philippe Plantier
Subject: [Wesnoth-cvs-commits] wesnoth/src builder.cpp builder.hpp config.cpp ...
Date: Sat, 11 Sep 2004 17:28:18 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Philippe Plantier <address@hidden>      04/09/11 21:22:57

Modified files:
        src            : builder.cpp builder.hpp config.cpp display.cpp 
                         display.hpp game.cpp playlevel.cpp 
                         playlevel.hpp 

Log message:
        Made it possible to have [terrain_graphics] rule as childs of 
[scenario]s.
        Fixed a bug where tiles from terrain_graphics rule did not have the 
per-rule
        image when only defined through [map].

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/builder.cpp.diff?tr1=1.33&tr2=1.34&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/builder.hpp.diff?tr1=1.24&tr2=1.25&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/config.cpp.diff?tr1=1.107&tr2=1.108&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/display.cpp.diff?tr1=1.258&tr2=1.259&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/display.hpp.diff?tr1=1.82&tr2=1.83&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/game.cpp.diff?tr1=1.124&tr2=1.125&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playlevel.cpp.diff?tr1=1.151&tr2=1.152&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playlevel.hpp.diff?tr1=1.17&tr2=1.18&r1=text&r2=text

Patches:
Index: wesnoth/src/builder.cpp
diff -u wesnoth/src/builder.cpp:1.33 wesnoth/src/builder.cpp:1.34
--- wesnoth/src/builder.cpp:1.33        Sat Sep 11 17:17:20 2004
+++ wesnoth/src/builder.cpp     Sat Sep 11 21:22:57 2004
@@ -1,4 +1,4 @@
-/* $Id: builder.cpp,v 1.33 2004/09/11 17:17:20 gruikya Exp $ */
+/* $Id: builder.cpp,v 1.34 2004/09/11 21:22:57 gruikya Exp $ */
 /*
    Copyright (C) 2004 by Philippe Plantier <address@hidden>
    Part of the Battle for Wesnoth Project http://www.wesnoth.org
@@ -135,10 +135,11 @@
        return map_[(loc.x+1) + (loc.y+1)*(x_+2)];
 }
 
-terrain_builder::terrain_builder(const config& cfg, const gamemap& gmap) :
+terrain_builder::terrain_builder(const config& cfg, const config& level, const 
gamemap& gmap) :
        map_(gmap), tile_map_(gmap.x(), gmap.y())
 {
        parse_config(cfg);
+       parse_config(level);
        build_terrains();
        //rebuild_terrain(gamemap::location(0,0));
 }
@@ -522,8 +523,10 @@
        }
 }
 
-void terrain_builder::add_constraints(std::map<gamemap::location, 
terrain_builder::terrain_constraint> & constraints, 
-                                     const gamemap::location& loc, const 
std::string& type)
+void terrain_builder::add_constraints(
+               terrain_builder::constraint_set& constraints, 
+               const gamemap::location& loc,
+               const std::string& type, const config& global_images)
 {
        if(constraints.find(loc) == constraints.end()) {
                //the terrain at the current location did not exist, so create 
it
@@ -532,6 +535,12 @@
 
        if(!type.empty())
                constraints[loc].terrain_types = type;                  
+       
+       int x = loc.x * rule_image::TILEWIDTH / 2;
+       int y = loc.y * rule_image::TILEWIDTH + (loc.x % 2) * 
+               rule_image::TILEWIDTH / 2;
+       add_images_from_config(constraints[loc].images, global_images, true, x, 
y);
+
 }
 
 void terrain_builder::add_constraint_item(std::vector<std::string> &list, 
const config& cfg, const std::string &item)
@@ -548,7 +557,7 @@
 
 void terrain_builder::add_constraints(terrain_builder::constraint_set 
&constraints, const gamemap::location& loc, const config& cfg, const config& 
global_images)
 {
-       add_constraints(constraints, loc, cfg["type"]);
+       add_constraints(constraints, loc, cfg["type"], global_images);
 
        terrain_constraint& constraint = constraints[loc];
        
@@ -556,16 +565,12 @@
        add_constraint_item(constraint.has_flag, cfg, "has_flag");
        add_constraint_item(constraint.no_flag, cfg, "no_flag");
 
-       int x = loc.x * rule_image::TILEWIDTH / 2;
-       int y = loc.y * rule_image::TILEWIDTH + (loc.x % 2) * 
-               rule_image::TILEWIDTH / 2;
-
        add_images_from_config(constraint.images, cfg, false);
-       add_images_from_config(constraint.images, global_images, true, x, y);
 }
 
 void terrain_builder::parse_mapstring(const std::string &mapstring,
-               struct building_rule &br, anchormap& anchors)
+               struct building_rule &br, anchormap& anchors,
+               const config& global_images)
 {
        int lineno = 0;
        int x = 0;
@@ -611,7 +616,7 @@
                                anchors.insert(std::pair<int, 
gamemap::location>(anchor, gamemap::location(x, lineno / 2)));
                        } else {
                                const gamemap::location loc(x, lineno / 2);
-                               add_constraints(br.constraints, loc, types);
+                               add_constraints(br.constraints, loc, types, 
global_images);
                        }
                        lpos += 4;
                        x += 2;
@@ -667,7 +672,7 @@
                anchormap anchors;
                
                // Parse the map= , if there is one (and fill the anchors list)
-               parse_mapstring((**br)["map"], pbr, anchors);
+               parse_mapstring((**br)["map"], pbr, anchors, **br);
 
                // Parses the terrain constraints (TCs)
                config::child_list tcs((*br)->get_children("tile"));
@@ -981,6 +986,12 @@
        building_ruleset::const_iterator rule;
        
        for(rule = building_rules_.begin(); rule != building_rules_.end(); 
++rule) {
+
+               if (rule->second.location_constraints.valid()) {
+                       apply_rule(rule->second, 
rule->second.location_constraints);
+                       continue;
+               }
+
                constraint_set::const_iterator constraint;
 
                //find the constraint that contains the less terrain of all 
terrain rules.
Index: wesnoth/src/builder.hpp
diff -u wesnoth/src/builder.hpp:1.24 wesnoth/src/builder.hpp:1.25
--- wesnoth/src/builder.hpp:1.24        Sat Sep 11 17:17:20 2004
+++ wesnoth/src/builder.hpp     Sat Sep 11 21:22:57 2004
@@ -1,4 +1,4 @@
-/* $Id: builder.hpp,v 1.24 2004/09/11 17:17:20 gruikya Exp $ */
+/* $Id: builder.hpp,v 1.25 2004/09/11 21:22:57 gruikya Exp $ */
 /*
    Copyright (C) 2004 by Philippe Plantier <address@hidden>
    Part of the Battle for Wesnoth Project http://www.wesnoth.org
@@ -40,7 +40,7 @@
        enum ADJACENT_TERRAIN_TYPE { ADJACENT_BACKGROUND, ADJACENT_FOREGROUND };
        typedef std::vector<animated<image::locator> > imagelist;
 
-       terrain_builder(const config& cfg, const gamemap& gmap);
+       terrain_builder(const config& cfg, const config &level, const gamemap& 
gmap);
 
        //returns a vector of string representing the images to load & blit 
together to get the
        //built content for this tile.
@@ -116,7 +116,7 @@
        typedef std::vector<rule_image> rule_imagelist;
 
        /**
-        * Each terrain_graphics rule consists in a set of constraints.
+        * Each terrain_graphics rule consists in a set of constraints
         */
        struct terrain_constraint
        {
@@ -210,13 +210,15 @@
                        int dx=0, int dy=0);
 
        void add_constraints(std::map<gamemap::location, terrain_constraint>& 
constraints,
-                       const gamemap::location &loc, const std::string& type);
+                       const gamemap::location &loc, const std::string& type,
+                       const config& global_images);
        void add_constraints(std::map<gamemap::location, terrain_constraint>& 
constraints,
-                       const gamemap::location &loc, const config &cfg, const 
config& global_images);
+                       const gamemap::location &loc, const config &cfg,
+                       const config& global_images);
        
        typedef std::multimap<int, gamemap::location> anchormap;
        void parse_mapstring(const std::string &mapstring, struct building_rule 
&br,
-                            anchormap& anchors);
+                            anchormap& anchors, const config& global_images);
        void parse_config(const config &cfg);
        bool terrain_matches(gamemap::TERRAIN letter, const std::string 
&terrains);
        bool rule_matches(const building_rule &rule, const gamemap::location 
&loc, int rule_index, bool check_loc);
Index: wesnoth/src/config.cpp
diff -u wesnoth/src/config.cpp:1.107 wesnoth/src/config.cpp:1.108
--- wesnoth/src/config.cpp:1.107        Sat Sep  4 23:55:07 2004
+++ wesnoth/src/config.cpp      Sat Sep 11 21:22:57 2004
@@ -1,4 +1,4 @@
-/* $Id: config.cpp,v 1.107 2004/09/04 23:55:07 isaaccp Exp $ */
+/* $Id: config.cpp,v 1.108 2004/09/11 21:22:57 gruikya Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -74,13 +74,6 @@
        return res;
 }
 
-#if 0
-struct close_FILE
-{
-       void operator()(FILE* f) const { if(f != NULL) { fclose(f); } }
-};
-#endif
-
 void read_file_internal(const std::string& fname, std::string& res)
 {
        const int size = file_size(fname);
Index: wesnoth/src/display.cpp
diff -u wesnoth/src/display.cpp:1.258 wesnoth/src/display.cpp:1.259
--- wesnoth/src/display.cpp:1.258       Sun Aug 29 19:31:39 2004
+++ wesnoth/src/display.cpp     Sat Sep 11 21:22:57 2004
@@ -1,4 +1,4 @@
-/* $Id: display.cpp,v 1.258 2004/08/29 19:31:39 gruikya Exp $ */
+/* $Id: display.cpp,v 1.259 2004/09/11 21:22:57 gruikya Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -54,7 +54,7 @@
 
 display::display(unit_map& units, CVideo& video, const gamemap& map,
                const gamestatus& status, const std::vector<team>& t, const 
config& theme_cfg,
-               const config& built_terrains) :
+               const config& config, const config& level) :
        screen_(video), xpos_(0), ypos_(0),
        zoom_(DefaultZoom), map_(map), units_(units),
        minimap_(NULL), redrawMinimap_(false),
@@ -65,7 +65,7 @@
        currentTeam_(0), activeTeam_(0), hideEnergy_(false),
        deadAmount_(0.0), advancingAmount_(0.0), updatesLocked_(0),
        turbo_(false), grid_(false), sidebarScaling_(1.0),
-       theme_(theme_cfg,screen_area()), builder_(built_terrains, map),
+       theme_(theme_cfg,screen_area()), builder_(config, level, map),
        first_turn_(true), in_game_(false), map_labels_(*this,map),
        tod_hex_mask1(NULL), tod_hex_mask2(NULL), diagnostic_label_(0),
        help_string_(0)
Index: wesnoth/src/display.hpp
diff -u wesnoth/src/display.hpp:1.82 wesnoth/src/display.hpp:1.83
--- wesnoth/src/display.hpp:1.82        Wed Aug 25 20:05:12 2004
+++ wesnoth/src/display.hpp     Sat Sep 11 21:22:57 2004
@@ -1,4 +1,4 @@
-/* $Id: display.hpp,v 1.82 2004/08/25 20:05:12 gruikya Exp $ */
+/* $Id: display.hpp,v 1.83 2004/09/11 21:22:57 gruikya Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -53,9 +53,9 @@
        typedef std::map<gamemap::location,unit> unit_map;
 
        display(unit_map& units, CVideo& video,
-               const gamemap& map, const gamestatus& status,
+                       const gamemap& map, const gamestatus& status,
                        const std::vector<team>& t, const config& theme_cfg,
-               const config& built_terrains);
+                       const config& config, const config& level);
        ~display();
 
        Uint32 rgb(Uint8 red, Uint8 green, Uint8 blue);
Index: wesnoth/src/game.cpp
diff -u wesnoth/src/game.cpp:1.124 wesnoth/src/game.cpp:1.125
--- wesnoth/src/game.cpp:1.124  Wed Sep  8 01:36:48 2004
+++ wesnoth/src/game.cpp        Sat Sep 11 21:22:57 2004
@@ -1,4 +1,4 @@
-/* $Id: game.cpp,v 1.124 2004/09/08 01:36:48 Sirp Exp $ */
+/* $Id: game.cpp,v 1.125 2004/09/11 21:22:57 gruikya Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -538,7 +538,7 @@
                display::unit_map u_map;
                config dummy_cfg("");
                display 
disp(u_map,video,gamemap(dummy_cfg,"1"),gamestatus(dummy_cfg,0),
-                            std::vector<team>(),dummy_cfg,dummy_cfg);
+                            std::vector<team>(),dummy_cfg,dummy_cfg,dummy_cfg);
 
                gui::show_dialog(disp,NULL,"","Error loading game configuration 
files: '" + e.message + "' (The game will now exit)",
                                 gui::MESSAGE);
@@ -599,7 +599,7 @@
                display::unit_map u_map;
                config dummy_cfg("");
                display 
disp(u_map,video,gamemap(dummy_cfg,"1"),gamestatus(dummy_cfg,0),
-                            std::vector<team>(),dummy_cfg,dummy_cfg);
+                            std::vector<team>(),dummy_cfg,dummy_cfg,dummy_cfg);
 
                std::cerr << "initialized display object\n";
                std::cerr << (SDL_GetTicks() - start_ticks) << "\n";
Index: wesnoth/src/playlevel.cpp
diff -u wesnoth/src/playlevel.cpp:1.151 wesnoth/src/playlevel.cpp:1.152
--- wesnoth/src/playlevel.cpp:1.151     Sat Aug 21 20:44:13 2004
+++ wesnoth/src/playlevel.cpp   Sat Sep 11 21:22:57 2004
@@ -1,4 +1,4 @@
-/* $Id: playlevel.cpp,v 1.151 2004/08/21 20:44:13 gruikya Exp $ */
+/* $Id: playlevel.cpp,v 1.152 2004/09/11 21:22:57 gruikya Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -112,9 +112,9 @@
 }
 
 LEVEL_RESULT play_level(game_data& gameinfo, const config& game_config,
-                        config* level, CVideo& video,
-                        game_state& state_of_game,
-                                               const std::vector<config*>& 
story)
+               config* level, CVideo& video,
+               game_state& state_of_game,
+               const std::vector<config*>& story)
 {
        const int ticks = SDL_GetTicks();
        std::cerr << "in play_level()...\n";
@@ -339,7 +339,7 @@
 
        std::cerr << "initializing display... " << (SDL_GetTicks() - ticks) << 
"\n";
        const config dummy_cfg;
-       display gui(units,video,map,status,teams,theme_cfg != NULL ? *theme_cfg 
: dummy_cfg, game_config);
+       display gui(units,video,map,status,teams,theme_cfg != NULL ? *theme_cfg 
: dummy_cfg, game_config, *level);
 
        std::cerr << "done initializing display... " << (SDL_GetTicks() - 
ticks) << "\n";
 
Index: wesnoth/src/playlevel.hpp
diff -u wesnoth/src/playlevel.hpp:1.17 wesnoth/src/playlevel.hpp:1.18
--- wesnoth/src/playlevel.hpp:1.17      Sun Aug 29 11:48:34 2004
+++ wesnoth/src/playlevel.hpp   Sat Sep 11 21:22:57 2004
@@ -1,4 +1,4 @@
-/* $Id: playlevel.hpp,v 1.17 2004/08/29 11:48:34 isaaccp Exp $ */
+/* $Id: playlevel.hpp,v 1.18 2004/09/11 21:22:57 gruikya Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -45,8 +45,8 @@
 };
 
 LEVEL_RESULT play_level(game_data& gameinfo, const config& terrain_config,
-                        config* level, CVideo& video,
-                        game_state& state_of_game,
-                                               const std::vector<config*>& 
story);
+               config* level, CVideo& video,
+               game_state& state_of_game,
+               const std::vector<config*>& story);
 
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]