Author: suokko
Date: Tue Sep 2 22:28:24 2008
New Revision: 29216
URL: http://svn.gna.org/viewcvs/wesnoth?rev=29216&view=rev
Log:
Fixed multiplayer replay switching to next side after victory/defeat, removed
bogus end turn caused by linger mode (bug #9157)
Modified:
trunk/src/multiplayer_connect.cpp
trunk/src/playmp_controller.cpp
trunk/src/playsingle_controller.cpp
trunk/src/playsingle_controller.hpp
trunk/src/replay.cpp
trunk/src/replay_controller.cpp
trunk/src/unit_map.cpp
Modified: trunk/src/multiplayer_connect.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/multiplayer_connect.cpp?rev=29216&r1=29215&r2=29216&view=diff
==============================================================================
--- trunk/src/multiplayer_connect.cpp (original)
+++ trunk/src/multiplayer_connect.cpp Tue Sep 2 22:28:24 2008
@@ -643,7 +643,6 @@
res["side"] = lexical_cast<std::string>(index_ + 1);
}
res["controller"] = controller_names[controller_];
- res["id"] = id_;
res["current_player"] = id_.empty() ? current_player_ : id_;
if (id_.empty()) {
@@ -656,7 +655,7 @@
if(enabled_ && cfg_.get_attribute("save_id").empty()) {
res["save_id"] = preferences::login() +
res["side"].str();
}
- res["id"] = preferences::login();
+ res["id"] = preferences::login() + res["side"].str();
res["current_player"] = preferences::login();
description = N_("Anonymous local player");
break;
@@ -665,6 +664,7 @@
res["save_id"] = "ai" + res["side"].str();
}
{
+ res["id"] = res["save_id"];
config *ai = res.child("ai");
if (!ai) ai = &res.add_child("ai");
#ifdef HAVE_PYTHON
@@ -699,6 +699,7 @@
}
res["user_description"] = t_string(description, "wesnoth");
} else {
+ res["id"] = id_ + res["side"];
if(enabled_ && cfg_.get_attribute("save_id").empty()) {
res["save_id"] = id_ + res["side"].str();
}
Modified: trunk/src/playmp_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playmp_controller.cpp?rev=29216&r1=29215&r2=29216&view=diff
==============================================================================
--- trunk/src/playmp_controller.cpp (original)
+++ trunk/src/playmp_controller.cpp Tue Sep 2 22:28:24 2008
@@ -124,6 +124,7 @@
}
void playmp_controller::before_human_turn(bool save){
+ LOG_NG << "playmp::before_human_turn...\n";
playsingle_controller::before_human_turn(save);
turn_data_ = new turn_info(gamestate_,status_,
@@ -173,6 +174,7 @@
}
void playmp_controller::play_human_turn(){
+ LOG_NG << "playmp::play_human_turn...\n";
int cur_ticks = SDL_GetTicks();
if ((!linger_) || (is_host_))
@@ -326,6 +328,7 @@
turn_data_->host_transfer().attach_handler(this);
play_human_turn();
+ turn_over_ = true; // We don't want to linger mode to
add end_turn to replay
after_human_turn();
LOG_NG << "finished human turn" << std::endl;
} catch (game::load_game_exception&) {
@@ -413,6 +416,7 @@
current_team().set_countdown_time(1000 * secs);
recorder.add_countdown_update(current_team().countdown_time(),player_number_);
}
+ LOG_NG << "playmp::after_human_turn...\n";
end_turn_record();
//send one more time to make sure network is up-to-date.
Modified: trunk/src/playsingle_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playsingle_controller.cpp?rev=29216&r1=29215&r2=29216&view=diff
==============================================================================
--- trunk/src/playsingle_controller.cpp (original)
+++ trunk/src/playsingle_controller.cpp Tue Sep 2 22:28:24 2008
@@ -673,6 +673,20 @@
gui_->draw();
}
}
+struct set_completion
+{
+ set_completion(game_state& state, const std::string& completion) :
+ state_(state), completion_(completion)
+ {
+ }
+ ~set_completion()
+ {
+ state_.completion = completion_;
+ }
+ private:
+ game_state& state_;
+ const std::string completion_;
+};
void playsingle_controller::linger(upload_log& log)
{
@@ -687,7 +701,7 @@
// this is actually for after linger mode is over -- we don't
// want to stay stuck in linger state when the *next* scenario
// is over.
- gamestate_.completion = "running";
+ set_completion setter(gamestate_,"running");
// change the end-turn button text to its alternate label
gui_->get_theme().refresh_title2(std::string("button-endturn"),
std::string("title2"));
Modified: trunk/src/playsingle_controller.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playsingle_controller.hpp?rev=29216&r1=29215&r2=29216&view=diff
==============================================================================
--- trunk/src/playsingle_controller.hpp (original)
+++ trunk/src/playsingle_controller.hpp Tue Sep 2 22:28:24 2008
@@ -81,8 +81,8 @@
bool end_turn_;
bool player_type_changed_;
bool replaying_;
+ bool turn_over_;
private:
- bool turn_over_;
void report_victory(std::stringstream& report,
end_level_exception& end_level,
int player_gold,
Modified: trunk/src/replay.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/replay.cpp?rev=29216&r1=29215&r2=29216&view=diff
==============================================================================
--- trunk/src/replay.cpp (original)
+++ trunk/src/replay.cpp Tue Sep 2 22:28:24 2008
@@ -820,6 +820,8 @@
DBG_REPLAY << "Repaly data at end\n";
}
+ ERR_REPLAY << *cfg << "\n";
+
//if we are expecting promotions here
if(advancing_units.empty() == false) {
Modified: trunk/src/replay_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/replay_controller.cpp?rev=29216&r1=29215&r2=29216&view=diff
==============================================================================
--- trunk/src/replay_controller.cpp (original)
+++ trunk/src/replay_controller.cpp Tue Sep 2 22:28:24 2008
@@ -181,6 +181,7 @@
statistics::fresh_stats();
if (events_manager_ != NULL){
delete events_manager_;
+ events_manager_ = 0;
events_manager_ = new game_events::manager(level_,map_,
units_,teams_,
gamestate_,status_);
events_manager_->set_gui(*gui_);
@@ -332,7 +333,7 @@
// If a side is empty skip over it.
if (current_team().is_empty()) return;
- statistics::reset_turn_stats(teams_[team_index-1].save_id());
+ statistics::reset_turn_stats(current_team().save_id());
try{
play_controller::init_side(player_number_ - 1, true);
Modified: trunk/src/unit_map.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_map.cpp?rev=29216&r1=29215&r2=29216&view=diff
==============================================================================
--- trunk/src/unit_map.cpp (original)
+++ trunk/src/unit_map.cpp Tue Sep 2 22:28:24 2008
@@ -25,6 +25,7 @@
#define ERR_NG LOG_STREAM(err, engine)
#define WRN_NG LOG_STREAM(warn, engine)
#define LOG_NG LOG_STREAM(info, engine)
+#define DBG_NG LOG_STREAM(debug, engine)
typedef std::pair<std::string, std::pair<bool, std::pair<gamemap::location,
unit>*> > umap_pair;
@@ -467,6 +468,8 @@
<< "," << iter->second.second->first.y+1 << ").\n";
}
+ DBG_NG << "Adding unit " << p->second.underlying_id() << "\n";
+
std::pair<lmap::iterator,bool> res =
lmap_.insert(std::pair<gamemap::location,std::string>(p->first, unit_id));
assert(res.second);
}
@@ -475,13 +478,17 @@
{
if (erase(p->first) != 1)
assert(0);
+ DBG_NG << "Replace unit " << p->second.underluig_id() << "\n";
add(p);
}
void unit_map::delete_all()
{
for (umap::iterator i = map_.begin(); i != map_.end(); ++i) {
- if (i->second.first) delete(i->second.second);
+ if (i->second.first) {
+ DBG_NG << "Delete unit " <<
i->second.second.underluig_id() << "\n";
+ delete(i->second.second);
+ }
}
lmap_.clear();
@@ -497,6 +504,7 @@
umap::iterator iter = map_.find(i->second);
std::pair<gamemap::location,unit> *res = iter->second.second;
+ DBG_NG << "Extract unit " << iter->second << "\n";
invalidate(iter);
lmap_.erase(i);
@@ -510,6 +518,7 @@
return 0;
umap::iterator iter = map_.find(i->second);
+ DBG_NG << "Replace unit " << i->second << "\n";
invalidate(iter);
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits