summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/being.cpp13
-rw-r--r--src/emoteshortcut.cpp2
-rw-r--r--src/net/ea/beinghandler.cpp4
-rw-r--r--src/resources/emotedb.cpp33
-rw-r--r--src/resources/emotedb.h11
5 files changed, 30 insertions, 33 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 9411cbe8b..d5012ac06 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -2785,12 +2785,21 @@ void Being::setEmote(const uint8_t emotion, const int emote_time)
if (emotionIndex >= 0 && emotionIndex <= EmoteDB::getLast())
{
delete mEmotionSprite;
- mEmotionSprite = EmoteDB::getClone(emotionIndex, true);
+ const EmoteInfo *const info = EmoteDB::get2(emotionIndex, true);
+ if (info)
+ {
+ const EmoteSprite *const sprite = info->sprites.front();
+ if (sprite)
+ {
+ mEmotionSprite = AnimatedSprite::clone(sprite->sprite);
+ if (mEmotionSprite)
+ mEmotionTime = info->time;
+ }
+ }
}
if (mEmotionSprite)
{
- mEmotionTime = emote_time;
mEmotionSprite->play(mSpriteAction);
mEmotionSprite->setSpriteDirection(static_cast<SpriteDirection>(
mSpriteDirection));
diff --git a/src/emoteshortcut.cpp b/src/emoteshortcut.cpp
index 900581983..9a908ca1b 100644
--- a/src/emoteshortcut.cpp
+++ b/src/emoteshortcut.cpp
@@ -48,7 +48,7 @@ void EmoteShortcut::load()
i <= sz && j < SHORTCUT_EMOTES;
i++)
{
- const AnimatedSprite *const sprite = EmoteDB::getAnimation(i, true);
+ const EmoteSprite *const sprite = EmoteDB::getSprite(i, true);
if (sprite)
{
mEmotes[j] = static_cast<unsigned char>(i + 1);
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index db3db9dd4..ea668589c 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -58,8 +58,6 @@
namespace Ea
{
-const int EMOTION_TIME = 500; /**< Duration of emotion icon */
-
BeingHandler::BeingHandler(const bool enableSync) :
mSync(enableSync),
mSpawnId(0),
@@ -578,7 +576,7 @@ void BeingHandler::processBeingEmotion(Net::MessageIn &msg) const
const unsigned char emote = msg.readInt8();
if (emote)
{
- dstBeing->setEmote(emote, EMOTION_TIME);
+ dstBeing->setEmote(emote, 0);
player_node->imitateEmote(dstBeing, emote);
}
}
diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp
index 9142b7c0e..09e3551dc 100644
--- a/src/resources/emotedb.cpp
+++ b/src/resources/emotedb.cpp
@@ -81,6 +81,7 @@ void EmoteDB::load()
}
EmoteInfo *const currentInfo = new EmoteInfo;
+ currentInfo->time = XML::getProperty(emoteNode, "time", 500);
for_each_xml_child_node(spriteNode, emoteNode)
{
@@ -136,6 +137,7 @@ void EmoteDB::load()
const int altId = XML::getProperty(emoteNode, "altid", -1);
EmoteInfo *const currentInfo = new EmoteInfo;
+ currentInfo->time = XML::getProperty(emoteNode, "time", 500);
for_each_xml_child_node(spriteNode, emoteNode)
{
@@ -218,30 +220,25 @@ const EmoteInfo *EmoteDB::get(const int id, const bool allowNull)
}
}
-const AnimatedSprite *EmoteDB::getAnimation(const int id, const bool allowNull)
-{
- const EmoteInfo *const info = get(id, allowNull);
- if (!info)
- return nullptr;
-
- return info->sprites.front()->sprite;
-}
-
-const AnimatedSprite *EmoteDB::getAnimation2(int id, const bool allowNull)
+const EmoteInfo *EmoteDB::get2(int id, const bool allowNull)
{
const EmoteToEmote::const_iterator it = mEmotesAlt.find(id);
if (it != mEmotesAlt.end())
id = (*it).second;
- return getAnimation(id, allowNull);
-}
-AnimatedSprite *EmoteDB::getClone(const int id, const bool allowNull)
-{
- const AnimatedSprite *const sprite = getAnimation2(id, allowNull);
- if (sprite)
- return AnimatedSprite::clone(sprite);
+ const EmoteInfos::const_iterator i = mEmoteInfos.find(id);
- return nullptr;
+ if (i == mEmoteInfos.end())
+ {
+ if (allowNull)
+ return nullptr;
+ logger->log("EmoteDB: Warning, unknown emote ID %d requested", id);
+ return &mUnknown;
+ }
+ else
+ {
+ return i->second;
+ }
}
const EmoteSprite *EmoteDB::getSprite(const int id, const bool allowNull)
diff --git a/src/resources/emotedb.h b/src/resources/emotedb.h
index 6a6463dfb..d8edb99ec 100644
--- a/src/resources/emotedb.h
+++ b/src/resources/emotedb.h
@@ -55,6 +55,7 @@ struct EmoteInfo final
std::list<EmoteSprite*> sprites;
StringVect particles;
+ int time;
};
typedef std::map<int, EmoteInfo*> EmoteInfos;
@@ -72,15 +73,7 @@ namespace EmoteDB
const EmoteInfo *get(const int id,
const bool allowNull = false) A_WARN_UNUSED;
- const AnimatedSprite *getAnimation(const int id,
- const bool allowNull = false)
- A_WARN_UNUSED;
-
- const AnimatedSprite *getAnimation2(int id,
- const bool allowNull = false)
- A_WARN_UNUSED;
-
- AnimatedSprite *getClone(const int id, const bool allowNull);
+ const EmoteInfo *get2(int id, const bool allowNull = false) A_WARN_UNUSED;
const EmoteSprite *getSprite(const int id, const bool allowNull = false)
A_WARN_UNUSED;