[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src game.cpp replay.cpp statistics.cpp ...
From: |
Jon Daniel |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src game.cpp replay.cpp statistics.cpp ... |
Date: |
Thu, 24 Mar 2005 16:56:44 -0500 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Jon Daniel <address@hidden> 05/03/24 21:56:44
Modified files:
src : game.cpp replay.cpp statistics.cpp
statistics.hpp
Log message:
Applied patch #3849 from cyberjack: fixes statistics are incorrectly
modified during replay
added a verifaction for the generated statistics
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/game.cpp.diff?tr1=1.213&tr2=1.214&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/replay.cpp.diff?tr1=1.97&tr2=1.98&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/statistics.cpp.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/statistics.hpp.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
Patches:
Index: wesnoth/src/game.cpp
diff -u wesnoth/src/game.cpp:1.213 wesnoth/src/game.cpp:1.214
--- wesnoth/src/game.cpp:1.213 Thu Mar 24 21:35:50 2005
+++ wesnoth/src/game.cpp Thu Mar 24 21:56:44 2005
@@ -1,4 +1,4 @@
-/* $Id: game.cpp,v 1.213 2005/03/24 21:35:50 ydirson Exp $ */
+/* $Id: game.cpp,v 1.214 2005/03/24 21:56:44 j_daniel Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -101,10 +101,6 @@
scenario =
game_config.find_child(type,"id",state.scenario);
std::cerr << "scenario found: " << (scenario != NULL ?
"yes" : "no") << "\n";
}
-
- if(!recorder.at_end()) {
- statistics::clear_current_scenario();
- }
} else {
std::cerr << "loading snapshot...\n";
//load from a save-snapshot.
@@ -866,27 +862,35 @@
}
recorder = replay(state_.replay_data);
+ recorder.start_replay();
+ recorder.set_skip(0);
std::cerr << "has snapshot: " << (state_.snapshot.child("side") ? "yes"
: "no") << "\n";
- //only play replay data if the user has selected to view the replay,
- //or if there is no starting position data to use.
- if(!show_replay && state_.snapshot.child("side") != NULL) {
- std::cerr << "setting replay to end...\n";
- recorder.set_to_end();
- if(!recorder.at_end()) {
- std::cerr << "recorder is not at the end!!!\n";
+ if(state_.snapshot.child("side") == NULL) {
+ // No snapshot; this is a start-of-scenario
+ if (show_replay) {
+ // There won't be any turns to replay, but the
+ // user gets to watch the intro sequence again ...
+ std::cerr << "replaying (start of scenario)\n";
+ } else {
+ std::cerr << "skipping...\n";
+ recorder.set_skip(-1);
}
} else {
-
- recorder.start_replay();
-
- //set whether the replay is to be skipped or not
+ // We have a snapshot. But does the user want to see a replay?
if(show_replay) {
- recorder.set_skip(0);
+ // clear the stats for the current level
+ // they will be regenerated during the replay
+ statistics::replay_verify_stats =
statistics::write_stats();
+ statistics::clear_current_scenario();
+ std::cerr << "replaying (snapshot)\n";
} else {
- std::cerr << "skipping...\n";
- recorder.set_skip(-1);
+ std::cerr << "setting replay to end...\n";
+ recorder.set_to_end();
+ if(!recorder.at_end()) {
+ std::cerr << "recorder is not at the end!!!\n";
+ }
}
}
Index: wesnoth/src/replay.cpp
diff -u wesnoth/src/replay.cpp:1.97 wesnoth/src/replay.cpp:1.98
--- wesnoth/src/replay.cpp:1.97 Tue Mar 22 22:09:28 2005
+++ wesnoth/src/replay.cpp Thu Mar 24 21:56:44 2005
@@ -1,4 +1,4 @@
-/* $Id: replay.cpp,v 1.97 2005/03/22 22:09:28 ydirson Exp $ */
+/* $Id: replay.cpp,v 1.98 2005/03/24 21:56:44 j_daniel Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -594,6 +594,11 @@
//if there is nothing more in the records
if(cfg == NULL) {
replayer.set_skip(0);
+ const config current_stats = statistics::write_stats();
+ if(current_stats != statistics::replay_verify_stats) {
+ ERR_NW << "replay statistics verifaction
failed\n";
+ if (!game_config::ignore_replay_errors) throw
replay::error();
+ }
return false;
}
Index: wesnoth/src/statistics.cpp
diff -u wesnoth/src/statistics.cpp:1.13 wesnoth/src/statistics.cpp:1.14
--- wesnoth/src/statistics.cpp:1.13 Thu Dec 23 20:03:53 2004
+++ wesnoth/src/statistics.cpp Thu Mar 24 21:56:44 2005
@@ -438,4 +438,5 @@
return res;
}
+config replay_verify_stats;
}
Index: wesnoth/src/statistics.hpp
diff -u wesnoth/src/statistics.hpp:1.9 wesnoth/src/statistics.hpp:1.10
--- wesnoth/src/statistics.hpp:1.9 Thu Mar 10 22:03:32 2005
+++ wesnoth/src/statistics.hpp Thu Mar 24 21:56:44 2005
@@ -82,6 +82,8 @@
std::vector<std::string> get_categories();
stats calculate_stats(int category, int side);
+
+ extern config replay_verify_stats;
}
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth/src game.cpp replay.cpp statistics.cpp ...,
Jon Daniel <=