summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-05-23 01:51:17 +0300
committerAndrei Karas <akaras@inbox.ru>2011-05-23 01:51:17 +0300
commitfe39570810969993f51a0ff6045d0a5d4397a5e5 (patch)
tree6d9641f625fdee333143934c0251cfa0dd870bd3
parentcff9e8d8f4bd6b678ad420c9e17eff729eecae4d (diff)
downloadplus-fe39570810969993f51a0ff6045d0a5d4397a5e5.tar.gz
plus-fe39570810969993f51a0ff6045d0a5d4397a5e5.tar.bz2
plus-fe39570810969993f51a0ff6045d0a5d4397a5e5.tar.xz
plus-fe39570810969993f51a0ff6045d0a5d4397a5e5.zip
Show speach messages variable time, depend on message size.
-rw-r--r--src/being.cpp6
-rw-r--r--src/being.h5
-rw-r--r--src/map.cpp10
-rw-r--r--src/net/manaserv/chathandler.cpp2
-rw-r--r--src/net/tmwa/chathandler.cpp4
-rw-r--r--src/playerrelations.cpp2
6 files changed, 18 insertions, 11 deletions
diff --git a/src/being.cpp b/src/being.cpp
index df698cf30..b995338a4 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -447,6 +447,12 @@ void Being::setSpeech(const std::string &text, int time)
if (mSpeech.length() < 1)
return;
+ if (!time && mSpeech.size() < 200)
+ time = SPEECH_TIME - 300 + (3 * mSpeech.size());
+
+ if (time < SPEECH_MIN_TIME)
+ time = SPEECH_MIN_TIME;
+
// Check for links
std::string::size_type start = mSpeech.find('[');
std::string::size_type end = mSpeech.find(']', start);
diff --git a/src/being.h b/src/being.h
index 91cafa69a..04cee8bcc 100644
--- a/src/being.h
+++ b/src/being.h
@@ -50,7 +50,8 @@
#define STATUS_EFFECTS 32
#define SPEECH_TIME 500
-#define SPEECH_MAX_TIME 1000
+#define SPEECH_MIN_TIME 200
+#define SPEECH_MAX_TIME 800
class AnimatedSprite;
class BeingCacheEntry;
@@ -239,7 +240,7 @@ class Being : public ActorSprite, public ConfigListener
* @param text The text that should appear.
* @param time The amount of time the text should stay in milliseconds.
*/
- void setSpeech(const std::string &text, int time = 500);
+ void setSpeech(const std::string &text, int time = 0);
/**
* Puts a damage bubble above this being.
diff --git a/src/map.cpp b/src/map.cpp
index e9ce78bd0..87e0ccbc6 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -1488,19 +1488,19 @@ void Map::setPvpMode(int mode)
switch (mPvp)
{
case 0:
- player_node->setSpeech("pvp off, gvg off", SPEECH_TIME);
+ player_node->setSpeech("pvp off, gvg off");
break;
case 1:
- player_node->setSpeech("pvp on", SPEECH_TIME);
+ player_node->setSpeech("pvp on");
break;
case 2:
- player_node->setSpeech("gvg on", SPEECH_TIME);
+ player_node->setSpeech("gvg on");
break;
case 3:
- player_node->setSpeech("pvp on, gvg on", SPEECH_TIME);
+ player_node->setSpeech("pvp on, gvg on");
break;
default:
- player_node->setSpeech("unknown pvp", SPEECH_TIME);
+ player_node->setSpeech("unknown pvp");
break;
}
}
diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp
index bdb903fe1..9fc85be2d 100644
--- a/src/net/manaserv/chathandler.cpp
+++ b/src/net/manaserv/chathandler.cpp
@@ -164,7 +164,7 @@ void ChatHandler::handleGameChatMessage(Net::MessageIn &msg)
if (being)
{
mes = being->getName() + " : " + chatMsg;
- being->setSpeech(chatMsg, SPEECH_TIME);
+ being->setSpeech(chatMsg);
}
else
mes = "Unknown : " + chatMsg;
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
index d8a842003..3a3b45a3c 100644
--- a/src/net/tmwa/chathandler.cpp
+++ b/src/net/tmwa/chathandler.cpp
@@ -278,7 +278,7 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
if (player_relations.hasPermission(sender_name,
PlayerRelation::SPEECH_FLOAT))
{
- being->setSpeech(chatMsg, SPEECH_TIME);
+ being->setSpeech(chatMsg);
}
break;
}
@@ -315,7 +315,7 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
trim(chatMsg);
if (player_node)
- player_node->setSpeech(chatMsg, SPEECH_TIME);
+ player_node->setSpeech(chatMsg);
}
else if (localChatTab)
{
diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp
index ae953cd75..4b40eff33 100644
--- a/src/playerrelations.cpp
+++ b/src/playerrelations.cpp
@@ -425,7 +425,7 @@ public:
return;
logger->log("ignoring: " + being->getName());
- being->setSpeech("...", 500);
+ being->setSpeech("...");
}
};