GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1525706-artifacts into lp:widelands.
Commit message: Fixed checking for artifacts on a map. Requested reviews: Widelands Developers (widelands-dev) Related bugs: Bug #1525706 in widelands: "Wincondition artifacts could be choosen if no artifacts are available in map" https://bugs.launchpad.net/widelands/+bug/1525706 For more details, see: https://code.launchpad.net/~widelands-dev/widelands/bug-1525706-artifacts/+merge/285566 The old function was semantic nonsense... -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1525706-artifacts into lp:widelands.
=== modified file 'src/editor/ui_menus/editor_main_menu_save_map.cc' --- src/editor/ui_menus/editor_main_menu_save_map.cc 2016-01-31 10:57:58 +0000 +++ src/editor/ui_menus/editor_main_menu_save_map.cc 2016-02-10 08:20:28 +0000 @@ -277,7 +277,7 @@ map.delete_tag("seafaring"); } - if (map.has_artifacts(egbase.world())) { + if (map.has_artifacts()) { map.add_tag("artifacts"); } else { map.delete_tag("artifacts"); === modified file 'src/logic/map.cc' --- src/logic/map.cc 2016-02-07 09:30:20 +0000 +++ src/logic/map.cc 2016-02-10 08:20:28 +0000 @@ -2121,11 +2121,15 @@ return false; } -bool Map::has_artifacts(const World& world) { - for (int32_t i = 0; i < world.get_nr_immovables(); ++i) { - const ImmovableDescr& descr = *world.get_immovable_descr(i); - if (descr.has_attribute(descr.get_attribute_id("artifact"))) { - return true; +bool Map::has_artifacts() { + for (FCoords c(Coords(0, 0), m_fields.get()); c.y < m_height; ++c.y) { + for (c.x = 0; c.x < m_width; ++c.x, ++c.field) { + assert(c.field == &operator[] (c)); + if (upcast(Immovable, immovable, c.field->get_immovable())) { + if (immovable->descr().has_attribute(immovable->descr().get_attribute_id("artifact"))) { + return true; + } + } } } return false; === modified file 'src/logic/map.h' --- src/logic/map.h 2016-02-05 20:07:10 +0000 +++ src/logic/map.h 2016-02-10 08:20:28 +0000 @@ -433,7 +433,9 @@ const PortSpacesSet& get_port_spaces() const {return m_port_spaces;} std::vector<Coords> find_portdock(const Widelands::Coords& c) const; bool allows_seafaring(); - bool has_artifacts(const World& world); + + /// Checks whether there are any artifacts on the map + bool has_artifacts(); protected: /// These functions are needed in Testclasses void set_size(uint32_t w, uint32_t h);
_______________________________________________ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp