[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src multiplayer_create.cpp
From: |
David White |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src multiplayer_create.cpp |
Date: |
Fri, 16 Sep 2005 20:12:18 -0400 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: David White <address@hidden> 05/09/17 00:12:17
Modified files:
src : multiplayer_create.cpp
Log message:
fixed problem where any bad multiplayer map would prevent starting a
multiplayer game at all
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/multiplayer_create.cpp.diff?tr1=1.35&tr2=1.36&r1=text&r2=text
Patches:
Index: wesnoth/src/multiplayer_create.cpp
diff -u wesnoth/src/multiplayer_create.cpp:1.35
wesnoth/src/multiplayer_create.cpp:1.36
--- wesnoth/src/multiplayer_create.cpp:1.35 Tue Sep 6 13:53:14 2005
+++ wesnoth/src/multiplayer_create.cpp Sat Sep 17 00:12:17 2005
@@ -1,4 +1,4 @@
-/* $Id: multiplayer_create.cpp,v 1.35 2005/09/06 13:53:14 ott Exp $ */
+/* $Id: multiplayer_create.cpp,v 1.36 2005/09/17 00:12:17 Sirp Exp $ */
/*
Copyright (C)
Part of the Battle for Wesnoth Project http://www.wesnoth.org
@@ -12,6 +12,8 @@
*/
#include "global.hpp"
+
+#include <memory>
#include "display.hpp"
#include "gettext.hpp"
@@ -19,7 +21,8 @@
#include "show_dialog.hpp"
#include "map_create.hpp"
#include "multiplayer_create.hpp"
-#include "filesystem.hpp"
+#include "filesystem.hpp"
+#include "log.hpp"
#include "preferences.hpp"
#include "video.hpp"
#include "serialization/string_utils.hpp"
@@ -299,12 +302,22 @@
generator_settings_.hide(generator_ == NULL);
regenerate_map_.hide(generator_ == NULL);
- const std::string& map_data =
parameters_.scenario_data["map_data"];
- gamemap map(game_config(), map_data);
+ const std::string& map_data =
parameters_.scenario_data["map_data"];
+
+ std::auto_ptr<gamemap> map(NULL);
+ try {
+ map.reset(new gamemap(game_config(), map_data));
+ } catch(gamemap::incorrect_format_exception& e) {
+ LOG_STREAM(err,general) << "map could not be loaded: "
<< e.msg_ << "\n";
+ tooltips::clear_tooltips(minimap_rect_);
+ tooltips::add_tooltip(minimap_rect_,e.msg_);
+ }
+
+ launch_game_.enable(map.get() != NULL);
//if there are less sides in the configuration than there are
starting
//positions, then generate the additional sides
- const int map_positions = map.num_valid_starting_positions();
+ const int map_positions = map.get() != NULL ?
map->num_valid_starting_positions() : 0;
for(int pos =
parameters_.scenario_data.get_children("side").size(); pos < map_positions;
++pos) {
config& side =
parameters_.scenario_data.add_child("side");
@@ -320,22 +333,29 @@
parameters_.scenario_data.remove_child("side",
parameters_.scenario_data.get_children("side").size()-1);
}
+
+ if(map.get() != NULL) {
+ const surface
mini(image::getMinimap(minimap_rect_.w,minimap_rect_.h,*map,0));
+ if(mini != NULL) {
+ SDL_Rect rect = minimap_rect_;
+ SDL_BlitSurface(mini, NULL,
video().getSurface(), &rect);
+ update_rect(rect);
+ }
+ }
- const surface
mini(image::getMinimap(minimap_rect_.w,minimap_rect_.h,map,0));
- if(mini != NULL) {
- SDL_Rect rect = minimap_rect_;
- SDL_BlitSurface(mini, NULL, video().getSurface(),
&rect);
- update_rect(rect);
- }
const int nsides =
parameters_.scenario_data.get_children("side").size();
- std::stringstream players;
- players << _("Players: ") << nsides;
+ std::stringstream players;
+ if(map.get() != NULL) {
+ players << _("Players: ") << nsides;
+ } else {
+ players << _("Error");
+ }
num_players_label_.set_text(players.str());
if(use_map_settings_.checked()) {
try {
xp_modifier_slider_.set_value(lexical_cast<int>(parameters_.scenario_data["experience_modifier"]));
- } catch(bad_lexical_cast bad_lexical) {
+ } catch(bad_lexical_cast&) {
xp_modifier_slider_.set_value(preferences::xp_modifier());
}
}
@@ -377,14 +397,20 @@
} else {
minimap_restorer_.assign(new surface_restorer(&video(),
minimap_rect_));
- const std::string& map_data =
parameters_.scenario_data["map_data"];
- gamemap map(game_config(), map_data);
- const surface
mini(image::getMinimap(minimap_rect_.w,minimap_rect_.h,map,0));
- if(mini != NULL) {
- SDL_Rect rect = minimap_rect_;
- SDL_BlitSurface(mini, NULL, video().getSurface(),
&rect);
- update_rect(rect);
- }
+ const std::string& map_data =
parameters_.scenario_data["map_data"];
+
+ try {
+ gamemap map(game_config(), map_data);
+ const surface
mini(image::getMinimap(minimap_rect_.w,minimap_rect_.h,map,0));
+ if(mini != NULL) {
+ SDL_Rect rect = minimap_rect_;
+ SDL_BlitSurface(mini, NULL,
video().getSurface(), &rect);
+ update_rect(rect);
+ }
+ } catch(gamemap::incorrect_format_exception& e) {
+ LOG_STREAM(err,general) << "map could not be loaded: "
<< e.msg_ << "\n";
+ }
+
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth/src multiplayer_create.cpp,
David White <=