diff --git a/src/playturn.cpp b/src/playturn.cpp index 503f0ba70ba..9b547b10e44 100644 --- a/src/playturn.cpp +++ b/src/playturn.cpp @@ -117,14 +117,6 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg preferences::message_bell()); } - if (cfg.has_child("turn") && cfg.child("turn").has_child("command") && - cfg.child("turn").child("command").has_child("speak")) { - config& msg = const_cast(cfg).child("turn").child("command").child("speak"); - const time_t time_ = time(NULL); - std::stringstream ss; - ss << time_; - msg["time"] = ss.str(); - } if (const config &msg = cfg.child("whisper") /*&& is_observer()*/) { resources::screen->add_chat_message(time(NULL), "whisper: " + msg["sender"].str(), 0, diff --git a/src/replay.cpp b/src/replay.cpp index 3e2b7087cbd..78e275fa979 100644 --- a/src/replay.cpp +++ b/src/replay.cpp @@ -125,6 +125,22 @@ static void verify(const unit_map& units, const config& cfg) { LOG_REPLAY << "verification passed\n"; } +static time_t get_time(const config &speak) +{ + time_t time; + if (!speak["time"].empty()) + { + std::stringstream ss(speak["time"].str()); + ss >> time; + } + else + { + //fallback in case sender uses wesnoth that doesn't send timestamps + time = ::time(NULL); + } + return time; +} + // FIXME: this one now has to be assigned with set_random_generator // from play_level or similar. We should surely hunt direct // references to it from this very file and move it out of here. @@ -149,8 +165,7 @@ chat_msg::chat_msg(const config &cfg) } else { color_ = team::get_side_highlight_pango(side-1); } - std::stringstream ss(cfg["time"].str()); - ss >> time_; + time_ = get_time(cfg); /* } else if (side==1) { color_ = "red"; @@ -939,7 +954,7 @@ bool do_replay_handle(int side_num, const std::string &do_untill) get_replay_source().add_chat_message_location(); if (!get_replay_source().is_skipping() || is_whisper) { int side = child["side"]; - resources::screen->add_chat_message(time(NULL), speaker_name, side, message, + resources::screen->add_chat_message(get_time(child), speaker_name, side, message, (team_name.empty() ? events::chat_handler::MESSAGE_PUBLIC : events::chat_handler::MESSAGE_PRIVATE), preferences::message_bell());