summaryrefslogtreecommitdiff
path: root/src/emoteshortcut.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-02-15 14:15:27 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-02-15 14:15:34 +0100
commit278d9aa7eb084bd6f93e6ac1fd84033dc316ab5e (patch)
treee1a095b48e34b844405801f7240501fe89579b38 /src/emoteshortcut.cpp
parent2779eb792a04667958feab9b433c1c82392c0bc3 (diff)
downloadmana-278d9aa7eb084bd6f93e6ac1fd84033dc316ab5e.tar.gz
mana-278d9aa7eb084bd6f93e6ac1fd84033dc316ab5e.tar.bz2
mana-278d9aa7eb084bd6f93e6ac1fd84033dc316ab5e.tar.xz
mana-278d9aa7eb084bd6f93e6ac1fd84033dc316ab5e.zip
Fix handling of non-consecutive emote IDs
Previous code was assuming there would be no gaps in the emote IDs. Also cleaned up some confusion where the "emote ID" being passed around in the code was often offset by 1. Now it is only offset in communication with tmwAthena and when saving the shortcuts.
Diffstat (limited to 'src/emoteshortcut.cpp')
-rw-r--r--src/emoteshortcut.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/emoteshortcut.cpp b/src/emoteshortcut.cpp
index 37d05647..69692437 100644
--- a/src/emoteshortcut.cpp
+++ b/src/emoteshortcut.cpp
@@ -28,8 +28,7 @@
EmoteShortcut *emoteShortcut;
-EmoteShortcut::EmoteShortcut():
- mEmoteSelected(0)
+EmoteShortcut::EmoteShortcut()
{
load();
}
@@ -43,9 +42,7 @@ void EmoteShortcut::load()
{
for (int i = 0; i < SHORTCUT_EMOTES; i++)
{
- int emoteId = (int) config.getValue("emoteshortcut" + toString(i), i + 1);
-
- mEmotes[i] = emoteId;
+ mEmotes[i] = (int) config.getValue("emoteshortcut" + toString(i), i + 1);
}
}
@@ -53,18 +50,17 @@ void EmoteShortcut::save()
{
for (int i = 0; i < SHORTCUT_EMOTES; i++)
{
- const int emoteId = mEmotes[i] ? mEmotes[i] : 0;
- config.setValue("emoteshortcut" + toString(i), emoteId);
+ config.setValue("emoteshortcut" + toString(i), mEmotes[i]);
}
}
void EmoteShortcut::useEmote(int index)
{
- if ((index > 0) && (index <= SHORTCUT_EMOTES))
+ if (index >= 0 && index < SHORTCUT_EMOTES)
{
- if (mEmotes[index - 1] > 0)
- {
- local_player->emote(mEmotes[index - 1]);
- }
+ if (mEmotes[index] > 0)
+ {
+ local_player->emote(mEmotes[index] - 1);
+ }
}
}