summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/being/localplayer.cpp14
-rw-r--r--src/resources/db/emotedb.cpp15
-rw-r--r--src/resources/db/emotedb.h4
3 files changed, 29 insertions, 4 deletions
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 529f2c73a..84b18774c 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -66,6 +66,8 @@
#include "resources/iteminfo.h"
+#include "resources/db/emotedb.h"
+
#include "utils/gettext.h"
#include "utils/timer.h"
@@ -2988,14 +2990,18 @@ void LocalPlayer::crazyMoveA()
if (emo == '?')
{
srand(tick_time);
- emote(static_cast<unsigned char>(1 + (rand() % 13)));
+ emote(static_cast<unsigned char>(1 + (rand() % EmoteDB::size())));
}
else
{
+ unsigned char emoteId = 0;
if (emo >= '0' && emo <= '9')
- emote(static_cast<unsigned char>(emo - '0' + 1));
- else if (emo >= 'a' && emo <= 'd')
- emote(static_cast<unsigned char>(emo - 'a' + 11));
+ emoteId = static_cast<unsigned char>(emo - '0' + 1);
+ else if (emo >= 'a' && emo <= 'z')
+ emoteId = static_cast<unsigned char>(emo - 'a' + 11);
+ else if (emo >= 'A' && emo <= 'Z')
+ emoteId = static_cast<unsigned char>(emo - 'A' + 37);
+ emote(emoteId);
}
mCrazyMoveState ++;
diff --git a/src/resources/db/emotedb.cpp b/src/resources/db/emotedb.cpp
index 97ea95aa0..943628978 100644
--- a/src/resources/db/emotedb.cpp
+++ b/src/resources/db/emotedb.cpp
@@ -295,3 +295,18 @@ const int &EmoteDB::getLast()
{
return mLastEmote;
}
+
+int EmoteDB::size()
+{
+ return static_cast<signed int>(mEmoteInfos.size());
+}
+
+int EmoteDB::getIdByIndex(const int index)
+{
+ if (index < 0 || index >= static_cast<signed int>(mEmoteInfos.size()))
+ return 0;
+ EmoteInfos::const_iterator it = mEmoteInfos.begin();
+ for (int f = 0; f < index; f ++)
+ ++ it;
+ return (*it).first;
+}
diff --git a/src/resources/db/emotedb.h b/src/resources/db/emotedb.h
index 02683a99a..29a2a8de4 100644
--- a/src/resources/db/emotedb.h
+++ b/src/resources/db/emotedb.h
@@ -87,6 +87,10 @@ namespace EmoteDB
const int &getLast() A_WARN_UNUSED;
+ int getIdByIndex(const int index);
+
+ int size();
+
typedef EmoteInfos::iterator EmoteInfosIterator;
} // namespace EmoteDB