diff --git a/src/gui/dialogs/chat_log.cpp b/src/gui/dialogs/chat_log.cpp
index 8d0b5ff0e1f..b630a5ec8f6 100644
--- a/src/gui/dialogs/chat_log.cpp
+++ b/src/gui/dialogs/chat_log.cpp
@@ -29,6 +29,7 @@
#include "gui/widgets/slider.hpp"
#include "utils/foreach.tpp"
+#include "../../game_preferences.hpp"
#include "../../gamestatus.hpp"
#include "../../log.hpp"
#include "../../resources.hpp"
@@ -134,9 +135,9 @@ public:
std::string nick_prefix = "";
std::string nick_suffix =" ";
if (me) {
- str << nick_prefix << "<" << escape(t.nick()) << escape(t.text().substr(3))<<">" <viewing_side();
if(!is_observer()) {
@@ -2579,7 +2583,7 @@ void menu_handler::send_chat_message(const std::string& message, bool allies_onl
}
recorder.speak(cfg);
- add_chat_message(time(NULL), cfg["id"], side, message,
+ add_chat_message(time, cfg["id"], side, message,
private_message ? events::chat_handler::MESSAGE_PRIVATE : events::chat_handler::MESSAGE_PUBLIC);
}
diff --git a/src/replay.cpp b/src/replay.cpp
index daa9284e603..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,6 +165,7 @@ chat_msg::chat_msg(const config &cfg)
} else {
color_ = team::get_side_highlight_pango(side-1);
}
+ time_ = get_time(cfg);
/*
} else if (side==1) {
color_ = "red";
@@ -937,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());
diff --git a/src/replay.hpp b/src/replay.hpp
index 081cf91baeb..71fbe9655a9 100644
--- a/src/replay.hpp
+++ b/src/replay.hpp
@@ -37,12 +37,14 @@ public:
const std::string &text() const { return text_; }
const std::string &nick() const { return nick_; }
const std::string &color() const { return color_; }
+ const time_t &time() const { return time_; }
chat_msg(const config &cfg);
virtual ~chat_msg();
private:
std::string color_;
std::string nick_;
std::string text_;
+ time_t time_;
};
class replay: public rand_rng::rng