[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth src/game.cpp src/config.cpp src/config....
From: |
David White |
Subject: |
[Wesnoth-cvs-commits] wesnoth src/game.cpp src/config.cpp src/config.... |
Date: |
Fri, 10 Jun 2005 22:41:38 -0400 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: David White <address@hidden> 05/06/11 02:41:38
Modified files:
src : game.cpp config.cpp config.hpp
data : game.cfg
Log message:
made it so a corrupt user campaign won't stop the game from starting
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/game.cpp.diff?tr1=1.252&tr2=1.253&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/config.cpp.diff?tr1=1.139&tr2=1.140&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/config.hpp.diff?tr1=1.62&tr2=1.63&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/data/game.cfg.diff?tr1=1.162&tr2=1.163&r1=text&r2=text
Patches:
Index: wesnoth/data/game.cfg
diff -u wesnoth/data/game.cfg:1.162 wesnoth/data/game.cfg:1.163
--- wesnoth/data/game.cfg:1.162 Wed Jun 1 22:25:43 2005
+++ wesnoth/data/game.cfg Sat Jun 11 02:41:38 2005
@@ -22,7 +22,6 @@
{terrain_generator.cfg}
{campaigns}
-{~campaigns}
{help.cfg}
Index: wesnoth/src/config.cpp
diff -u wesnoth/src/config.cpp:1.139 wesnoth/src/config.cpp:1.140
--- wesnoth/src/config.cpp:1.139 Sat Jun 4 19:16:05 2005
+++ wesnoth/src/config.cpp Sat Jun 11 02:41:37 2005
@@ -1,4 +1,4 @@
-/* $Id: config.cpp,v 1.139 2005/06/04 19:16:05 ott Exp $ */
+/* $Id: config.cpp,v 1.140 2005/06/11 02:41:37 Sirp Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Copyright (C) 2005 by Guillaume Melquiond <address@hidden>
@@ -59,6 +59,22 @@
for(string_map::const_iterator j = cfg.values.begin(); j !=
cfg.values.end(); ++j) {
values[j->first] = j->second;
}
+}
+
+void config::merge_children(const std::string& key)
+{
+ config merged_children;
+ const child_list& children = get_children(key);
+ if(children.size() < 2) {
+ return;
+ }
+
+ for(child_list::const_iterator i = children.begin(); i !=
children.end(); ++i) {
+ merged_children.append(**i);
+ }
+
+ clear_children(key);
+ add_child(key,merged_children);
}
config::child_itors config::child_range(const std::string& key)
Index: wesnoth/src/config.hpp
diff -u wesnoth/src/config.hpp:1.62 wesnoth/src/config.hpp:1.63
--- wesnoth/src/config.hpp:1.62 Sat Jun 4 19:16:05 2005
+++ wesnoth/src/config.hpp Sat Jun 11 02:41:37 2005
@@ -1,4 +1,4 @@
-/* $Id: config.hpp,v 1.62 2005/06/04 19:16:05 ott Exp $ */
+/* $Id: config.hpp,v 1.63 2005/06/11 02:41:37 Sirp Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
@@ -122,7 +122,11 @@
//append data from another config object to this one. attributes in the
//latter config object will clobber attributes in this one.
- void append(const config& cfg);
+ void append(const config& cfg);
+
+ //all children with the given key will be merged into the first element
+ //with that key
+ void merge_children(const std::string& key);
//resets the translated values of all strings contained in this object
void reset_translation() const;
Index: wesnoth/src/game.cpp
diff -u wesnoth/src/game.cpp:1.252 wesnoth/src/game.cpp:1.253
--- wesnoth/src/game.cpp:1.252 Sat Jun 4 19:16:05 2005
+++ wesnoth/src/game.cpp Sat Jun 11 02:41:37 2005
@@ -1,4 +1,4 @@
-/* $Id: game.cpp,v 1.252 2005/06/04 19:16:05 ott Exp $ */
+/* $Id: game.cpp,v 1.253 2005/06/11 02:41:37 Sirp Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
@@ -1278,7 +1278,40 @@
scoped_istream stream =
preprocess_file("data/game.cfg", &defines);
std::string error_log;
- read(cfg, *stream, &error_log);
+ read(cfg, *stream, &error_log);
+
+ //load user campaigns
+ const std::string user_campaign_dir =
get_user_data_dir() + "/data/campaigns/";
+ std::vector<std::string> user_campaigns,
error_campaigns;
+
get_files_in_dir(user_campaign_dir,&user_campaigns,NULL,ENTIRE_FILE_PATH);
+ for(std::vector<std::string>::const_iterator uc
= user_campaigns.begin(); uc != user_campaigns.end(); ++uc) {
+ try {
+ scoped_istream stream =
preprocess_file(*uc,&defines);
+
+ config user_campaign_cfg;
+
read(user_campaign_cfg,*stream,NULL);
+ cfg.append(user_campaign_cfg);
+ } catch(config::error&) {
+ std::cerr << "error processing
user campaign '" << *uc << "'\n";
+ error_campaigns.push_back(*uc);
+ } catch(io_exception&) {
+ std::cerr << "error reading
user campaign '" << *uc << "'\n";
+ error_campaigns.push_back(*uc);
+ }
+ }
+
+ if(error_campaigns.empty() == false) {
+ std::stringstream msg;
+ msg << _("The following add-on
campaign(s) had errors and could not be loaded:");
+
for(std::vector<std::string>::const_iterator i = error_campaigns.begin(); i !=
error_campaigns.end(); ++i) {
+ msg << "\n" << *i;
+ }
+
+
gui::show_error_message(disp(),msg.str());
+ }
+
+ cfg.merge_children("units");
+
if(!error_log.empty()) {
gui::show_error_message(disp(),
_("Warning: Errors
occurred while loading game configuration files: '") +
@@ -1511,19 +1544,19 @@
return 0;
}
-#ifdef WIN32
- res = game.init_config();
- if(res == false) {
- std::cerr << "could not initialize game config\n";
- return 0;
- }
-#endif
-
res = game.init_video();
if(res == false) {
std::cerr << "could not initialize display\n";
return 0;
}
+
+#ifdef WIN32
+ res = game.init_config();
+ if(res == false) {
+ std::cerr << "could not initialize game config\n";
+ return 0;
+ }
+#endif
res = game.init_language();
if(res == false) {
@@ -1618,6 +1651,10 @@
}
return 0;
+}
+
+void f() {
+ throw config::error("");
}
int main(int argc, char** argv)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth src/game.cpp src/config.cpp src/config....,
David White <=