From e41d434e4b71ab3245665cae957a205e94591a00 Mon Sep 17 00:00:00 2001 From: Foofoo_The_Guy <32585652+FoofooTheGuy@users.noreply.github.com> Date: Thu, 12 Feb 2026 12:38:47 -0500 Subject: [PATCH 1/5] clear message when there is an invalid ID --- Sources/Helpers/Chat.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Sources/Helpers/Chat.cpp b/Sources/Helpers/Chat.cpp index c386116..80be437 100644 --- a/Sources/Helpers/Chat.cpp +++ b/Sources/Helpers/Chat.cpp @@ -99,6 +99,12 @@ namespace CTRPluginFramework { } void Chat::CommandLoop() { + + //macro to clean up + #define CLEAR_RET \ + ClearPlayerMessage(); \ + return; + if(!IsPlayerMessageOnScreen()) { return; } @@ -135,7 +141,7 @@ namespace CTRPluginFramework { } else { OSDExtras::Notify(TextID::CHAT_INVALID_ANIMATION, Color::Red); - return; + CLEAR_RET } } @@ -146,7 +152,7 @@ namespace CTRPluginFramework { } else { OSDExtras::Notify(TextID::CHAT_INVALID_EMOTION, Color::Red); - return; + CLEAR_RET } } @@ -157,7 +163,7 @@ namespace CTRPluginFramework { } else { OSDExtras::Notify(TextID::CHAT_INVALID_SNAKE, Color::Red); - return; + CLEAR_RET } } @@ -168,7 +174,7 @@ namespace CTRPluginFramework { } else { OSDExtras::Notify(TextID::CHAT_INVALID_MUSIC, Color::Red); - return; + CLEAR_RET } } @@ -182,7 +188,7 @@ namespace CTRPluginFramework { } else { OSDExtras::Notify(TextID::INVALID_ITEM, Color::Red); - return; + CLEAR_RET } } @@ -191,13 +197,13 @@ namespace CTRPluginFramework { ItemNamePack match; if (!Item::searchByKeyword(ItemName, match)) { OSDExtras::Notify(TextID::CHAT_NO_ITEM_FOUND, Color::Red); - return; + CLEAR_RET } itemID = Item(match.ID); //sets item if(!itemID.isValid()) { //should always be true if orig file is used OSDExtras::Notify(TextID::INVALID_ITEM, Color::Red); - return; + CLEAR_RET } ItemCommand(); From 46245ccf4afeff9a4dcf5f8b93038b8f04dacc19 Mon Sep 17 00:00:00 2001 From: Foofoo_The_Guy <32585652+FoofooTheGuy@users.noreply.github.com> Date: Thu, 12 Feb 2026 12:42:47 -0500 Subject: [PATCH 2/5] fix comment style my bad --- Sources/Helpers/Chat.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Helpers/Chat.cpp b/Sources/Helpers/Chat.cpp index 80be437..0dd57b6 100644 --- a/Sources/Helpers/Chat.cpp +++ b/Sources/Helpers/Chat.cpp @@ -5,7 +5,7 @@ namespace CTRPluginFramework { u32 Chat::GetPlayerMessageData() { u8 _pID = Game::GetActualPlayerIndex(); - // swap your index with player 0 in order to get the correct pointer + //swap your index with player 0 in order to get the correct pointer if(_pID == Game::GetOnlinePlayerIndex()) { _pID = 0; } @@ -209,7 +209,7 @@ namespace CTRPluginFramework { ItemCommand(); } - else { // any other message + else { //any other message return; } ClearPlayerMessage(); From 8579ab3b0a7df71c42e2bdf0f99965e986f56315 Mon Sep 17 00:00:00 2001 From: Foofoo_The_Guy <32585652+FoofooTheGuy@users.noreply.github.com> Date: Sun, 15 Feb 2026 13:23:53 -0500 Subject: [PATCH 3/5] rearrange commandloop more functions, less nesting --- Sources/Helpers/Chat.cpp | 146 +++++++++++++++++++++------------------ 1 file changed, 77 insertions(+), 69 deletions(-) diff --git a/Sources/Helpers/Chat.cpp b/Sources/Helpers/Chat.cpp index 0dd57b6..5de1bf8 100644 --- a/Sources/Helpers/Chat.cpp +++ b/Sources/Helpers/Chat.cpp @@ -98,12 +98,77 @@ namespace CTRPluginFramework { } } - void Chat::CommandLoop() { + bool Chat::AnimationContext(const std::string &ID_8Bit) { + animID = StringToHex(ID_8Bit, 6); //sets animation + if(!IDList::AnimationValid(animID, GetPlayerIndex())) { + OSDExtras::Notify(TextID::CHAT_INVALID_ANIMATION, Color::Red); + return false; + } + AnimationCommand(); + return true; + } + + bool Chat::EmotionContext(const std::string &ID_8Bit) { + emotionID = StringToHex(ID_8Bit, 1); //sets emotion + if(!IDList::EmotionValid(emotionID)) { + OSDExtras::Notify(TextID::CHAT_INVALID_EMOTION, Color::Red); + return false; + } + EmotionCommand(); + return true; + } + + bool Chat::SnakeContext(const std::string &ID_12Bit) { + snakeID = StringToHex(ID_12Bit, 1); //sets snake + if(!IDList::SnakeValid(snakeID)) { + OSDExtras::Notify(TextID::CHAT_INVALID_SNAKE, Color::Red); + return false; + } + SnakeCommand(); + return true; + } + + bool Chat::MusicContext(const std::string &ID_12Bit) { + musicID = StringToHex(ID_12Bit, 0x660); //sets music + if(!IDList::MusicValid(musicID)) { + OSDExtras::Notify(TextID::CHAT_INVALID_MUSIC, Color::Red); + return false; + } + MusicCommand(); + return true; + } + + bool Chat::ItemContext(const std::string &ID_16Bit, const std::string &SPCommand, const std::string &SPID_16Bit) { + itemID.ID = StringToHex(ID_16Bit, 0x2001); //sets item + if(!itemID.isValid()) { + OSDExtras::Notify(TextID::INVALID_ITEM, Color::Red); + return false; + } + if(SPCommand == "f:") { + itemID.Flags = StringToHex(SPID_16Bit, 0); //sets flag + } + ItemCommand(); + return true; + } + + bool Chat::NameContext(std::string &ItemName) { + UtilsExtras::Trim(ItemName); + ItemNamePack match; + if (!Item::searchByKeyword(ItemName, match)) { + OSDExtras::Notify(TextID::CHAT_NO_ITEM_FOUND, Color::Red); + return false; + } - //macro to clean up - #define CLEAR_RET \ - ClearPlayerMessage(); \ - return; + itemID = Item(match.ID); //sets item + if(!itemID.isValid()) { //should always be true if orig file is used + OSDExtras::Notify(TextID::INVALID_ITEM, Color::Red); + return false; + } + ItemCommand(); + return false; + } + + void Chat::CommandLoop() { if(!IsPlayerMessageOnScreen()) { return; @@ -133,82 +198,25 @@ namespace CTRPluginFramework { //Item Name std::string ItemName = PlayerText.substr(2, 23); - + if(Command == "a:") { - animID = StringToHex(ID_8Bit, 6); //sets animation - if(IDList::AnimationValid(animID, GetPlayerIndex())) { - AnimationCommand(); - } - else { - OSDExtras::Notify(TextID::CHAT_INVALID_ANIMATION, Color::Red); - CLEAR_RET - } + AnimationContext(ID_8Bit); } - else if(Command == "e:") { - emotionID = StringToHex(ID_8Bit, 1); //sets emotion - if(IDList::EmotionValid(emotionID)) { - EmotionCommand(); - } - else { - OSDExtras::Notify(TextID::CHAT_INVALID_EMOTION, Color::Red); - CLEAR_RET - } + EmotionContext(ID_8Bit); } - else if(Command == "s:") { - snakeID = StringToHex(ID_12Bit, 1); //sets snake - if(IDList::SnakeValid(snakeID)) { - SnakeCommand(); - } - else { - OSDExtras::Notify(TextID::CHAT_INVALID_SNAKE, Color::Red); - CLEAR_RET - } + SnakeContext(ID_12Bit); } - else if(Command == "m:") { - musicID = StringToHex(ID_12Bit, 0x660); //sets music - if(IDList::MusicValid(musicID)) { - MusicCommand(); - } - else { - OSDExtras::Notify(TextID::CHAT_INVALID_MUSIC, Color::Red); - CLEAR_RET - } + MusicContext(ID_12Bit); } - else if(Command == "i:") { - itemID.ID = StringToHex(ID_16Bit, 0x2001); //sets item - if(itemID.isValid()) { - if(SPCommand == "f:") { - itemID.Flags = StringToHex(SPID_16Bit, 0); //sets flag - } - ItemCommand(); - } - else { - OSDExtras::Notify(TextID::INVALID_ITEM, Color::Red); - CLEAR_RET - } + ItemContext(ID_16Bit, SPCommand, SPID_16Bit); } - else if(Command == "n:") { - UtilsExtras::Trim(ItemName); - ItemNamePack match; - if (!Item::searchByKeyword(ItemName, match)) { - OSDExtras::Notify(TextID::CHAT_NO_ITEM_FOUND, Color::Red); - CLEAR_RET - } - - itemID = Item(match.ID); //sets item - if(!itemID.isValid()) { //should always be true if orig file is used - OSDExtras::Notify(TextID::INVALID_ITEM, Color::Red); - CLEAR_RET - } - - ItemCommand(); + NameContext(ItemName); } - else { //any other message return; } From 3bc8921e63aae74d707947bd7c247209b3f2b0d8 Mon Sep 17 00:00:00 2001 From: Foofoo_The_Guy <32585652+FoofooTheGuy@users.noreply.github.com> Date: Sun, 15 Feb 2026 13:24:20 -0500 Subject: [PATCH 4/5] Add the header too --- Includes/Helpers/Chat.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Includes/Helpers/Chat.hpp b/Includes/Helpers/Chat.hpp index 5bac89e..fc3f30b 100644 --- a/Includes/Helpers/Chat.hpp +++ b/Includes/Helpers/Chat.hpp @@ -24,13 +24,19 @@ namespace CTRPluginFramework { protected: static void CommandCallback(void); - private: + private: void CommandLoop(void); void AnimationCommand(void); void EmotionCommand(void); void SnakeCommand(void); void MusicCommand(void); void ItemCommand(void); + bool AnimationContext(const std::string &ID_8Bit); + bool EmotionContext(const std::string &ID_8Bit); + bool SnakeContext(const std::string &ID_12Bit); + bool MusicContext(const std::string &ID_12Bit); + bool ItemContext(const std::string &ID_16Bit, const std::string &SPCommand, const std::string &SPID_16Bit); + bool NameContext(std::string &ItemName); u8 animID = 6; u8 emotionID = 1; @@ -38,4 +44,4 @@ namespace CTRPluginFramework { u16 musicID = 0x660; CTRPluginFramework::Item itemID = { 0x7FFE, 0 }; }; -} \ No newline at end of file +} From f3ecf963d86b899a22e877a80d2730871d6fd2e1 Mon Sep 17 00:00:00 2001 From: Foofoo_The_Guy <32585652+FoofooTheGuy@users.noreply.github.com> Date: Fri, 27 Feb 2026 10:34:18 -0500 Subject: [PATCH 5/5] change false to true --- Sources/Helpers/Chat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Helpers/Chat.cpp b/Sources/Helpers/Chat.cpp index 5de1bf8..b52dccf 100644 --- a/Sources/Helpers/Chat.cpp +++ b/Sources/Helpers/Chat.cpp @@ -165,7 +165,7 @@ namespace CTRPluginFramework { return false; } ItemCommand(); - return false; + return true; } void Chat::CommandLoop() {