/windowstate crashes with skins that don't provide Text

A forum for reporting bugs NOT related to custom plugins.

Moderator: MacroQuest Developers

demonstar55
a snow griffon
a snow griffon
Posts: 314
Joined: Fri Nov 28, 2008 6:31 am

/windowstate crashes with skins that don't provide Text

Post by demonstar55 » Wed Sep 16, 2015 9:52 pm

Fix:

Code: Select all

VOID WindowState(PSPAWNINFO pChar, PCHAR szLine)
{
    CHAR Arg1[MAX_STRING] = {0};
    CHAR Arg2[MAX_STRING] = {0};
    GetArg(Arg1,szLine,1);
    GetArg(Arg2,szLine,2);
    if (PCSIDLWND pWnd=(PCSIDLWND)FindMQ2Window(Arg1)) 
    {
        DWORD ShowWindow = (DWORD)pWnd->pvfTable->ShowWindow;
        CHAR szBuffer[MAX_STRING] = {0};
        BYTE State=99;
        if (!stricmp(Arg2,"open")) State=1;
        if (!stricmp(Arg2,"close")) State=0;
        if (pWnd->dShow==State) State=99;
        switch (State) {
                case 0:
                    ((CXWnd*)pWnd)->Show(0,1);
                    sprintf(szBuffer,"Window '%s' is now closed.",pWnd->WindowText ? pWnd->WindowText->Text : Arg1);
                    ((CSidlScreenWnd*)pWnd)->StoreIniVis();
                    break;
                case 1:
                    __asm {
                        push ecx;
                        mov ecx, [pWnd];
                        call dword ptr [ShowWindow];
                        pop ecx;
                    }
                    sprintf(szBuffer,"Window '%s' is now open.",pWnd->WindowText ? pWnd->WindowText->Text : Arg1);
                    ((CSidlScreenWnd*)pWnd)->StoreIniVis();
                    break;
                case 99:
                    sprintf(szBuffer,"Window '%s' is currently %s",pWnd->WindowText ? pWnd->WindowText->Text : Arg1,(pWnd->dShow==0)?"closed":"open");
                    break;
        }
        WriteChatColor(szBuffer,USERCOLOR_DEFAULT);
        return;
    }
    SyntaxError("Usage: /windowstate <window> [open|close]");
}
http://pastebin.com/raw.php?i=4AMCv5Xg pastebin'd to not fuck up indents from copying from a forum.

Basically if there is a Text provided in the UI (custom UIs often don't bother), use that, otherwise use what the user provided to the command.

EqMule
Developer
Developer
Posts: 2697
Joined: Fri Jan 03, 2003 9:57 pm
Contact:

Re: /windowstate crashes with skins that don't provide Text

Post by EqMule » Thu Sep 17, 2015 6:57 am

added in next zip, thanks.
My status o/
If you like MQ2 and would like to contribute, please do. My goal is 25 donations per month.
So far I've received Image donations for this month's patches.

Bitcoin: 1Aq8ackjQ4f7AUvbUL7BE6oPfT8PmNP4Zq
Krono: PM me.
I can always use characters for testing, PM me if you can donate one.