Merge lp:~widelands-dev/widelands/s2_map into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 7556
Proposed branch: lp:~widelands-dev/widelands/s2_map
Merge into: lp:widelands
Diff against target: 170 lines (+65/-71)
3 files modified
src/editor/ui_menus/editor_main_menu_load_or_save_map.cc (+29/-32)
src/network/nethost.cc (+1/-1)
src/ui_fsmenu/mapselect.cc (+35/-38)
To merge this branch: bzr merge lp:~widelands-dev/widelands/s2_map
Reviewer Review Type Date Requested Status
SirVer Approve
Review via email: mp+274627@code.launchpad.net

Description of the change

Made Settlers II maps reappear in map selection windows.

I had accidentally killed them in r7538.

To post a comment you must log in.
Revision history for this message
SirVer (sirver) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/editor/ui_menus/editor_main_menu_load_or_save_map.cc'
2--- src/editor/ui_menus/editor_main_menu_load_or_save_map.cc 2015-10-02 09:26:57 +0000
3+++ src/editor/ui_menus/editor_main_menu_load_or_save_map.cc 2015-10-17 20:01:54 +0000
4@@ -171,39 +171,36 @@
5 Widelands::Map map;
6
7 for (const std::string& mapfilename : files) {
8-
9 // Add map file (compressed) or map directory (uncompressed)
10- if (Widelands::WidelandsMapLoader::is_widelands_map(mapfilename)) {
11- std::unique_ptr<Widelands::MapLoader> ml = map.get_correct_loader(mapfilename);
12- if (ml.get() != nullptr) {
13- try {
14- ml->preload_map(true);
15-
16- if (!map.get_width() || !map.get_height()) {
17- continue;
18- }
19-
20- MapData::MapType maptype;
21-
22- if (map.scenario_types() & Widelands::Map::MP_SCENARIO ||
23- map.scenario_types() & Widelands::Map::SP_SCENARIO) {
24- maptype = MapData::MapType::kScenario;
25- } else if (dynamic_cast<Widelands::WidelandsMapLoader*>(ml.get())) {
26- maptype = MapData::MapType::kNormal;
27- } else {
28- maptype = MapData::MapType::kSettlers2;
29- }
30-
31- MapData mapdata(map, mapfilename, maptype, display_type);
32-
33- has_translated_mapname_ =
34- has_translated_mapname_ || (mapdata.name != mapdata.localized_name);
35-
36- maps_data_.push_back(mapdata);
37-
38- } catch (const WException&) {
39- } // we simply skip illegal entries
40- }
41+ std::unique_ptr<Widelands::MapLoader> ml = map.get_correct_loader(mapfilename);
42+ if (ml != nullptr) {
43+ try {
44+ ml->preload_map(true);
45+
46+ if (!map.get_width() || !map.get_height()) {
47+ continue;
48+ }
49+
50+ MapData::MapType maptype;
51+
52+ if (map.scenario_types() & Widelands::Map::MP_SCENARIO ||
53+ map.scenario_types() & Widelands::Map::SP_SCENARIO) {
54+ maptype = MapData::MapType::kScenario;
55+ } else if (dynamic_cast<Widelands::WidelandsMapLoader*>(ml.get())) {
56+ maptype = MapData::MapType::kNormal;
57+ } else {
58+ maptype = MapData::MapType::kSettlers2;
59+ }
60+
61+ MapData mapdata(map, mapfilename, maptype, display_type);
62+
63+ has_translated_mapname_ =
64+ has_translated_mapname_ || (mapdata.name != mapdata.localized_name);
65+
66+ maps_data_.push_back(mapdata);
67+
68+ } catch (const WException&) {
69+ } // we simply skip illegal entries
70 } else if (g_fs->is_directory(mapfilename)) {
71 // Add subdirectory to the list
72 const char* fs_filename = FileSystem::fs_filename(mapfilename.c_str());
73
74=== modified file 'src/network/nethost.cc'
75--- src/network/nethost.cc 2015-09-04 06:16:58 +0000
76+++ src/network/nethost.cc 2015-10-17 20:01:54 +0000
77@@ -2650,7 +2650,7 @@
78 Widelands::Map map;
79 i18n::Textdomain td("maps");
80 std::unique_ptr<Widelands::MapLoader> ml = map.get_correct_loader(path);
81- if (ml.get() != nullptr) {
82+ if (ml != nullptr) {
83 // Yes it is a map file :)
84 map.set_filename(path);
85 ml->preload_map(true);
86
87=== modified file 'src/ui_fsmenu/mapselect.cc'
88--- src/ui_fsmenu/mapselect.cc 2015-10-05 06:53:34 +0000
89+++ src/ui_fsmenu/mapselect.cc 2015-10-17 20:01:54 +0000
90@@ -259,45 +259,42 @@
91 Widelands::Map map; // MapLoader needs a place to put its preload data
92
93 for (const std::string& mapfilename : files) {
94-
95 // Add map file (compressed) or map directory (uncompressed)
96- if (Widelands::WidelandsMapLoader::is_widelands_map(mapfilename)) {
97- std::unique_ptr<Widelands::MapLoader> ml = map.get_correct_loader(mapfilename);
98- if (ml.get() != nullptr) {
99- try {
100- map.set_filename(mapfilename);
101- ml->preload_map(true);
102-
103- if (!map.get_width() || !map.get_height()) {
104- continue;
105- }
106-
107- MapData::MapType maptype;
108- if (map.scenario_types() & scenario_types_) {
109- maptype = MapData::MapType::kScenario;
110- } else if (dynamic_cast<WidelandsMapLoader*>(ml.get())) {
111- maptype = MapData::MapType::kNormal;
112- } else {
113- maptype = MapData::MapType::kSettlers2;
114- }
115-
116- MapData mapdata(map, mapfilename, maptype, display_type);
117-
118- has_translated_mapname_ =
119- has_translated_mapname_ || (mapdata.name != mapdata.localized_name);
120-
121- bool has_all_tags = true;
122- for (std::set<uint32_t>::const_iterator it = req_tags_.begin(); it != req_tags_.end(); ++it)
123- has_all_tags &= mapdata.tags.count(tags_ordered_[*it]);
124- if (!has_all_tags) {
125- continue;
126- }
127- maps_data_.push_back(mapdata);
128- } catch (const std::exception & e) {
129- log("Mapselect: Skip %s due to preload error: %s\n", mapfilename.c_str(), e.what());
130- } catch (...) {
131- log("Mapselect: Skip %s due to unknown exception\n", mapfilename.c_str());
132- }
133+ std::unique_ptr<Widelands::MapLoader> ml = map.get_correct_loader(mapfilename);
134+ if (ml != nullptr) {
135+ try {
136+ map.set_filename(mapfilename);
137+ ml->preload_map(true);
138+
139+ if (!map.get_width() || !map.get_height()) {
140+ continue;
141+ }
142+
143+ MapData::MapType maptype;
144+ if (map.scenario_types() & scenario_types_) {
145+ maptype = MapData::MapType::kScenario;
146+ } else if (dynamic_cast<WidelandsMapLoader*>(ml.get())) {
147+ maptype = MapData::MapType::kNormal;
148+ } else {
149+ maptype = MapData::MapType::kSettlers2;
150+ }
151+
152+ MapData mapdata(map, mapfilename, maptype, display_type);
153+
154+ has_translated_mapname_ =
155+ has_translated_mapname_ || (mapdata.name != mapdata.localized_name);
156+
157+ bool has_all_tags = true;
158+ for (std::set<uint32_t>::const_iterator it = req_tags_.begin(); it != req_tags_.end(); ++it)
159+ has_all_tags &= mapdata.tags.count(tags_ordered_[*it]);
160+ if (!has_all_tags) {
161+ continue;
162+ }
163+ maps_data_.push_back(mapdata);
164+ } catch (const std::exception & e) {
165+ log("Mapselect: Skip %s due to preload error: %s\n", mapfilename.c_str(), e.what());
166+ } catch (...) {
167+ log("Mapselect: Skip %s due to unknown exception\n", mapfilename.c_str());
168 }
169 } else if (g_fs->is_directory(mapfilename)) {
170 // Add subdirectory to the list

Subscribers

People subscribed via source and target branches

to status/vote changes: