[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src dialogs.cpp game.cpp gamestatus.cpp...
From: |
Philippe Plantier |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src dialogs.cpp game.cpp gamestatus.cpp... |
Date: |
Tue, 05 Apr 2005 15:42:12 -0400 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Philippe Plantier <address@hidden> 05/04/05 19:42:07
Modified files:
src : dialogs.cpp game.cpp gamestatus.cpp
gamestatus.hpp multiplayer_connect.cpp
src/serialization: binary_or_text.cpp binary_or_text.hpp
Log message:
Enabled the loading of savegames to be tolerant to corrupt / badly
formed save
files, like those issued with some versions of the game.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/dialogs.cpp.diff?tr1=1.96&tr2=1.97&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/game.cpp.diff?tr1=1.223&tr2=1.224&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/gamestatus.cpp.diff?tr1=1.69&tr2=1.70&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/gamestatus.hpp.diff?tr1=1.43&tr2=1.44&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/multiplayer_connect.cpp.diff?tr1=1.139&tr2=1.140&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/serialization/binary_or_text.cpp.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/serialization/binary_or_text.hpp.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
Patches:
Index: wesnoth/src/dialogs.cpp
diff -u wesnoth/src/dialogs.cpp:1.96 wesnoth/src/dialogs.cpp:1.97
--- wesnoth/src/dialogs.cpp:1.96 Mon Apr 4 20:05:58 2005
+++ wesnoth/src/dialogs.cpp Tue Apr 5 19:42:03 2005
@@ -1,4 +1,4 @@
-/* $Id: dialogs.cpp,v 1.96 2005/04/04 20:05:58 ydirson Exp $ */
+/* $Id: dialogs.cpp,v 1.97 2005/04/05 19:42:03 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -475,7 +475,7 @@
try {
summary["mod_time"] =
str_cast(lexical_cast<int>(games[*s].time_modified));
- load_game(data,games[*s].name,state);
+ load_game(data,games[*s].name,state,NULL);
extract_summary_data_from_save(state,summary);
} catch(io_exception&) {
summary["corrupt"] = "yes";
Index: wesnoth/src/game.cpp
diff -u wesnoth/src/game.cpp:1.223 wesnoth/src/game.cpp:1.224
--- wesnoth/src/game.cpp:1.223 Sat Apr 2 21:33:21 2005
+++ wesnoth/src/game.cpp Tue Apr 5 19:42:05 2005
@@ -1,4 +1,4 @@
-/* $Id: game.cpp,v 1.223 2005/04/02 21:33:21 gruikya Exp $ */
+/* $Id: game.cpp,v 1.224 2005/04/05 19:42:05 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -743,8 +743,17 @@
//to load a save file, we first load the file in, then we
re-parse game
//data with the save's #defines, and then we finally parse the
save file,
//with the game data ready to go.
+
config cfg;
- read_save_file(game,cfg);
+ std::string error_log;
+ read_save_file(game,cfg,&error_log);
+ if(!error_log.empty()) {
+ // FIXME: fix this string after the string-freeze is
+ // over, to clearly state this is a warning.
+ gui::show_error_message(disp(),
+ _("The file you have tried to load is
corrupt: '") +
+ error_log);
+ }
defines_map_.clear();
defines_map_[cfg["difficulty"]] = preproc_define();
@@ -1382,6 +1391,8 @@
std::string error_log;
read(cfg, *stream, &line_src, &error_log);
if(!error_log.empty()) {
+ // FIXME: fix this string after the
string-freeze is
+ // over, to clearly state this is a
warning.
gui::show_error_message(disp(),
_("Error loading game
configuration files: '") +
error_log);
Index: wesnoth/src/gamestatus.cpp
diff -u wesnoth/src/gamestatus.cpp:1.69 wesnoth/src/gamestatus.cpp:1.70
--- wesnoth/src/gamestatus.cpp:1.69 Tue Apr 5 18:32:30 2005
+++ wesnoth/src/gamestatus.cpp Tue Apr 5 19:42:05 2005
@@ -1,4 +1,4 @@
-/* $Id: gamestatus.cpp,v 1.69 2005/04/05 18:32:30 gruikya Exp $ */
+/* $Id: gamestatus.cpp,v 1.70 2005/04/05 19:42:05 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -426,7 +426,7 @@
remove((get_saves_dir() + "/" + modified_name).c_str());
}
-void read_save_file(const std::string& name, config& cfg)
+void read_save_file(const std::string& name, config& cfg, std::string*
error_log)
{
std::string modified_name = name;
std::replace(modified_name.begin(),modified_name.end(),' ','_');
@@ -437,7 +437,7 @@
file_stream = istream_file(get_saves_dir() + "/" + name);
cfg.clear();
- detect_format_and_read(cfg, *file_stream);
+ detect_format_and_read(cfg, *file_stream, error_log);
if(cfg.empty()) {
std::cerr << "Could not parse file data into config\n";
@@ -445,12 +445,12 @@
}
}
-void load_game(const game_data& data, const std::string& name, game_state&
state)
+void load_game(const game_data& data, const std::string& name, game_state&
state, std::string* error_log)
{
log_scope("load_game");
config cfg;
- read_save_file(name,cfg);
+ read_save_file(name,cfg,error_log);
state = read_game(data,&cfg);
}
Index: wesnoth/src/gamestatus.hpp
diff -u wesnoth/src/gamestatus.hpp:1.43 wesnoth/src/gamestatus.hpp:1.44
--- wesnoth/src/gamestatus.hpp:1.43 Tue Apr 5 18:32:30 2005
+++ wesnoth/src/gamestatus.hpp Tue Apr 5 19:42:05 2005
@@ -1,4 +1,4 @@
-/* $Id: gamestatus.hpp,v 1.43 2005/04/05 18:32:30 gruikya Exp $ */
+/* $Id: gamestatus.hpp,v 1.44 2005/04/05 19:42:05 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -156,7 +156,7 @@
enum WRITE_GAME_MODE { WRITE_SNAPSHOT_ONLY, WRITE_FULL_GAME };
-void read_save_file(const std::string& name, config& cfg);
+void read_save_file(const std::string& name, config& cfg, std::string*
error_log);
game_state read_game(const game_data& data, const config* cfg);
void write_game(const game_state& game, config& cfg, WRITE_GAME_MODE
mode=WRITE_FULL_GAME);
@@ -165,7 +165,7 @@
bool save_game_exists(const std::string & name);
//functions to load/save games.
-void load_game(const game_data& data, const std::string& name, game_state&
state);
+void load_game(const game_data& data, const std::string& name, game_state&
state, std::string* error_log);
//throws gamestatus::save_game_failed
void save_game(const game_state& state);
Index: wesnoth/src/multiplayer_connect.cpp
diff -u wesnoth/src/multiplayer_connect.cpp:1.139
wesnoth/src/multiplayer_connect.cpp:1.140
--- wesnoth/src/multiplayer_connect.cpp:1.139 Sat Apr 2 10:36:12 2005
+++ wesnoth/src/multiplayer_connect.cpp Tue Apr 5 19:42:05 2005
@@ -1,4 +1,4 @@
-/* $Id: multiplayer_connect.cpp,v 1.139 2005/04/02 10:36:12 gruikya Exp $ */
+/* $Id: multiplayer_connect.cpp,v 1.140 2005/04/05 19:42:05 gruikya Exp $ */
/*
Copyright (C)
Part of the Battle for Wesnoth Project http://www.wesnoth.org
@@ -879,7 +879,13 @@
}
//state_.players.clear();
- ::load_game(game_data_, game, state_);
+ std::string error_log;
+ ::load_game(game_data_, game, state_, &error_log);
+ if(!error_log.empty()) {
+ gui::show_error_message(disp(),
+ _("The file you have tried to load is
corrupt: '") +
+ error_log);
+ }
if(state_.campaign_type != "multiplayer") {
gui::show_dialog(disp(), NULL, "", _("This is not a
multiplayer save"),
Index: wesnoth/src/serialization/binary_or_text.cpp
diff -u wesnoth/src/serialization/binary_or_text.cpp:1.7
wesnoth/src/serialization/binary_or_text.cpp:1.8
--- wesnoth/src/serialization/binary_or_text.cpp:1.7 Sat Mar 26 14:07:18 2005
+++ wesnoth/src/serialization/binary_or_text.cpp Tue Apr 5 19:42:07 2005
@@ -1,4 +1,4 @@
-/* $Id: binary_or_text.cpp,v 1.7 2005/03/26 14:07:18 silene Exp $ */
+/* $Id: binary_or_text.cpp,v 1.8 2005/04/05 19:42:07 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Copyright (C) 2005 by Guillaume Melquiond <address@hidden>
@@ -19,14 +19,14 @@
#include <sstream>
-bool detect_format_and_read(config &cfg, std::istream &in)
+bool detect_format_and_read(config &cfg, std::istream &in, std::string*
error_log)
{
unsigned char c = in.peek();
if (c < 4) {
read_compressed(cfg, in);
return true;
} else {
- read(cfg, in);
+ read(cfg, in, NULL, error_log);
return false;
}
}
Index: wesnoth/src/serialization/binary_or_text.hpp
diff -u wesnoth/src/serialization/binary_or_text.hpp:1.2
wesnoth/src/serialization/binary_or_text.hpp:1.3
--- wesnoth/src/serialization/binary_or_text.hpp:1.2 Sat Mar 26 14:07:18 2005
+++ wesnoth/src/serialization/binary_or_text.hpp Tue Apr 5 19:42:07 2005
@@ -1,4 +1,4 @@
-/* $Id: binary_or_text.hpp,v 1.2 2005/03/26 14:07:18 silene Exp $ */
+/* $Id: binary_or_text.hpp,v 1.3 2005/04/05 19:42:07 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Copyright (C) 2005 by Guillaume Melquiond <address@hidden>
@@ -22,7 +22,7 @@
//function which reads a file, and automatically detects whether it's
compressed or not before
//reading it. If it's not a valid file at all, it will throw an error as if it
was trying to
//read it as text WML. Returns true iff the format is compressed
-bool detect_format_and_read(config &cfg, std::istream &in); //throws
config::error
+bool detect_format_and_read(config &cfg, std::istream &in, std::string*
error_log=NULL); //throws config::error
//function which writes a file, compressed or not depending on a flag
void write_possibly_compressed(std::ostream &out, config &cfg, bool compress);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth/src dialogs.cpp game.cpp gamestatus.cpp...,
Philippe Plantier <=