fix freezes from server talks spam

This commit is contained in:
Eduardo Bart 2012-06-14 19:27:57 -03:00
parent 83f86eac64
commit fb36ff2da3
2 changed files with 6 additions and 4 deletions

View File

@ -54,13 +54,15 @@ bool StaticText::addMessage(const std::string& name, Otc::SpeakType type, const
m_name = name;
m_messageType = type;
}
else {
else if(m_messages.size() > 20) {
// to many messages, ignore to avoid lag
return false;
} else {
// we can only add another message if it follows these conditions
if(m_name != name || m_messageType != type)
return false;
}
m_messages.push_back(message);
compose();
auto self = asStaticText();
@ -73,7 +75,7 @@ bool StaticText::addMessage(const std::string& name, Otc::SpeakType type, const
void StaticText::removeMessage()
{
m_messages.erase(m_messages.begin());
m_messages.pop_front();
if(m_messages.empty()) {
// schedule removal

View File

@ -50,7 +50,7 @@ private:
void compose();
Boolean<false> m_yell;
std::vector<std::string> m_messages;
std::deque<std::string> m_messages;
std::string m_name;
Otc::SpeakType m_messageType;
Color m_color;