From 739f9dcb70d837697b6905e8256ba579a40d86fe Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 28 Jan 2009 21:00:26 +0000 Subject: interface cleanups, send_warn --- src/core/netplayer.cc | 2 +- src/core/netplayer.h | 2 +- src/core/player.cc | 7 +++++++ src/core/player.h | 17 ++++++++++++++++- 4 files changed, 25 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/netplayer.cc b/src/core/netplayer.cc index 24a597f..0b3455f 100644 --- a/src/core/netplayer.cc +++ b/src/core/netplayer.cc @@ -31,7 +31,7 @@ void NetPlayer::sound(const std::string name) player_client->send_raw(msg); } -void NetPlayer::message(Message::Channel channel, const std::string text) +void NetPlayer::message(const Message::Channel channel, const std::string text) { if (!text.size()) return; diff --git a/src/core/netplayer.h b/src/core/netplayer.h index bbabea6..5659e2e 100644 --- a/src/core/netplayer.h +++ b/src/core/netplayer.h @@ -27,7 +27,7 @@ public: NetClient *client() { return player_client; } - virtual void message(Message::Channel const channel, const std::string text); + virtual void message(const Message::Channel channel, const std::string text); virtual void sound(const std::string name); private: diff --git a/src/core/player.cc b/src/core/player.cc index a642371..6385992 100644 --- a/src/core/player.cc +++ b/src/core/player.cc @@ -42,6 +42,7 @@ void Player::clear() player_ping = 0; player_level = 1; + player_warningtime = 0; } @@ -64,6 +65,12 @@ void Player::send(const std::string text) message(core::Message::Info, text); } +void Player::send_warning(const std::string text) +{ + message(core::Message::Info, text); + player_warningtime = application()->time(); +} + void Player::sound(const std::string name) { application()->notify_sound(name.c_str()); diff --git a/src/core/player.h b/src/core/player.h index 4620062..35a2f82 100644 --- a/src/core/player.h +++ b/src/core/player.h @@ -88,11 +88,24 @@ public: /*----- messages -------------------------------------------------- */ - void send(const std::string name); + /// send a text message + void send(const std::string text); + + /** + * @brief send a warning message + * Send the player a warning message abd set the warning + * message timestamp to the current application time + * @see last_warning() + */ + void send_warning(const std::string text); virtual void sound(const std::string name); virtual void message(core::Message::Channel channel, const std::string text); + + /// time of the last warning message + float last_warning() const { return player_warningtime; } + /*----- mutators -------------------------------------------------- */ @@ -204,6 +217,8 @@ private: // bit to indicate zone has changed bool player_zonechange; + float player_warningtime; + }; } -- cgit v1.2.3