JZomDev / zom-external-plugins

BSD 2-Clause "Simplified" License
11 stars 7 forks source link

Slash Swapper | `///` sends to FC instead of guest clan with Swap Guest Chat disabled #40

Open Ririshi opened 3 months ago

Ririshi commented 3 months ago

Hi there, I'm the maintainer of Smart Chat Input Color, a plugin that colors the chat input based on the channel that it will go to. I've found a bug in your plugin, pretty much as the title says. Additionally, when on a non-GIM account type, the //// prefix is supposed to send to clan chat but has the same bug, sending to FC instead.

I currently accommodated the bug in my plugin by adding a "Slash Swapper bug" setting that defaults to true. If you have time to find the bug and fix it, I could change my plugin's setting to false by default in a future release :)

JZomDev commented 3 months ago

Since I don't have access to a GIM account and won't make one, can you fix it and submit a PR against my repo?

The Slash swapper relies on the script stack to reroute the channel it is meant to go into.


        if (intStack[intStackCount - 1] == 1 && intStack[intStackCount - 2] == 9)
        {
            // message is going to friends chat because user typed /
            intStack[intStackCount - 2] = !swapGuestChat ? 41 : 44; // swap it to clan chat or guest chat
        }
        else if (intStack[intStackCount - 1] == 2 && intStack[intStackCount - 2] == 41)
        {
            // message is going to clan chat because user typed //
            intStack[intStackCount - 2] = 9; // swap it to friends chat
        }
        else if (intStack[intStackCount - 1] == 3  && intStack[intStackCount - 2] == 44)
        {
            // message is going to guest chat because user typed ///
            intStack[intStackCount - 2] = !swapGuestChat ? 9 : 41; // swap it to friends chat or guest chat
        }
Ririshi commented 3 months ago

So just to be clear, in the last else if part, the !swapGuestChat ? 9 : 41 should never swap to FC, right? It should only swap to Clan Chat if swapGuestChat is set to true. I think that fixes both issues. So the new code could look like this:

else if (intStack[intStackCount - 1] == 3  && intStack[intStackCount - 2] == 44 && swapGuestChat)
{
    // message is going to guest chat because user typed ///
    // if swapGuestChat is enabled, it should go to clan chat instead
    intStack[intStackCount - 2] = 41;
}

I'm not sure what intStack[intStackCount - 1] means, though. Is that the number of slashes? In that case, there should be an extra else if case for four slashes. I could make a PR for that sometime soon and incorporate the above fix there, too.

JZomDev commented 3 months ago

The int stack is the parameters sent to the scripts, if I'm using 9 as the value it means to go into a specific text channel, if I switch it with another value it'll go some where else.

Friends chat is 9, clan is 41 and guest clan is 44.(if I'm reading my own code right) Group iron has their own number, I don't know what it is. That's what you can figure out for me.