From a79a1e6ac086355639fcbf995e1c6399199e4476 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 11 May 2012 23:26:03 +0300 Subject: Add alt emotes id support. Limit tmw emotes. --- src/being.cpp | 4 ++-- src/resources/emotedb.cpp | 16 +++++++++++++++- src/resources/emotedb.h | 3 +++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/being.cpp b/src/being.cpp index e8338df6c..69dfb9046 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -1430,8 +1430,8 @@ void Being::drawEmotion(Graphics *graphics, int offsetX, int offsetY) if (emotionIndex >= 0 && emotionIndex <= EmoteDB::getLast()) { - if (EmoteDB::getAnimation(emotionIndex, true)) - EmoteDB::getAnimation(emotionIndex)->draw(graphics, px, py); + if (EmoteDB::getAnimation2(emotionIndex, true)) + EmoteDB::getAnimation2(emotionIndex)->draw(graphics, px, py); else mEmotion = 0; } diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp index 045900415..b3628cdeb 100644 --- a/src/resources/emotedb.cpp +++ b/src/resources/emotedb.cpp @@ -22,6 +22,7 @@ #include "resources/emotedb.h" #include "animatedsprite.h" +#include "client.h" #include "logger.h" #include "utils/xml.h" @@ -32,6 +33,7 @@ namespace { EmoteInfos mEmoteInfos; + EmoteToEmote mEmotesAlt; EmoteInfo mUnknown; bool mLoaded = false; int mLastEmote = 0; @@ -69,7 +71,7 @@ void EmoteDB::load() int id = XML::getProperty(emoteNode, "id", -1); // skip hight images - if (id > 19) + if (id > 19 || (Client::isTmw() && id > 13)) continue; if (id == -1) @@ -133,6 +135,7 @@ void EmoteDB::load() "manaplus_emotes.xml!"); continue; } + int altId = XML::getProperty(emoteNode, "altid", -1); EmoteInfo *currentInfo = new EmoteInfo; @@ -161,6 +164,9 @@ void EmoteDB::load() } } mEmoteInfos[id] = currentInfo; + if (altId != -1) + mEmotesAlt[altId] = id; + if (id > mLastEmote) mLastEmote = id; } @@ -223,6 +229,14 @@ const AnimatedSprite *EmoteDB::getAnimation(int id, bool allowNull) return info->sprites.front()->sprite; } +const AnimatedSprite *EmoteDB::getAnimation2(int id, bool allowNull) +{ + EmoteToEmote::const_iterator it = mEmotesAlt.find(id); + if (it != mEmotesAlt.end()) + id = (*it).second; + return getAnimation(id, allowNull); +} + const EmoteSprite *EmoteDB::getSprite(int id, bool allowNull) { const EmoteInfo *info = get(id, allowNull); diff --git a/src/resources/emotedb.h b/src/resources/emotedb.h index 24ceb40db..847f3f0ee 100644 --- a/src/resources/emotedb.h +++ b/src/resources/emotedb.h @@ -42,6 +42,7 @@ struct EmoteInfo }; typedef std::map EmoteInfos; +typedef std::map EmoteToEmote; /** * Emote information database. @@ -56,6 +57,8 @@ namespace EmoteDB const AnimatedSprite *getAnimation(int id, bool allowNull = false); + const AnimatedSprite *getAnimation2(int id, bool allowNull = false); + const EmoteSprite *getSprite(int id, bool allowNull = false); const int &getLast(); -- cgit v1.2.3-70-g09d2