/endmacro not clearing vars

A forum for reporting bugs NOT related to custom plugins.

Moderator: MacroQuest Developers

tonio
a ghoul
a ghoul
Posts: 117
Joined: Fri Apr 02, 2004 12:57 am
Contact:

/endmacro not clearing vars

Post by tonio » Fri Apr 02, 2004 1:27 am

I noticed /endmacro was clearing arrays and timers, but not vars, starting a couple of releases ago (that is, less than a week ago). I checked the code and found this:

Code: Select all

// ***************************************************************************
// Function:    EndMacro
// Description: Our '/endmacro' command
// Usage:       /endmacro
// ***************************************************************************
VOID EndMacro(PSPAWNINFO pChar, PCHAR szLine)
{
    CHAR Buffer[MAX_STRING] = {0};
    DWORD i;
    PMACROBLOCK pPrev;
    PMACROSTACK pStack;
    PEVENTSTACK pEvent;
    PEVENTLIST pEventL;
    BOOL bKeepKeys = gKeepKeys;
    [color=red]BOOL bKeepVars = TRUE;[/color]
    BOOL bKeepTimers = FALSE;
    BOOL bKeepArrays = FALSE;
in MQ2MacroCommands.cpp.

Is this an oversight? I know it wasn't working like this before. I noticed because suddenly my macros were spewing a lot of "Variable so-and-so already defined" or something like that, when I stopped and restarted them.

Yes, I know you can pass arguments to /endmacro to keep or not keep arrays, vars, timers... but I was wondering why the default was changed, whether it was on purpose.

*Edit: funky BBCode end tag
Tonio

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Fri Apr 02, 2004 1:35 am

Lax changed this on purpose. Just throw a /zapvars right below your Sub Main in your macros.

tonio
a ghoul
a ghoul
Posts: 117
Joined: Fri Apr 02, 2004 12:57 am
Contact:

Post by tonio » Fri Apr 02, 2004 5:51 pm

Oh, I just changed the code and re-compiled... figured it was an oversight (kinda like when Lax forgot to put Parms as the default instead of MQ2Data). If it's not, then np, I'll change it back and adjust. =)

Outta sheer curiosity, tho, what's the reason behind it? (Looked around the forums and didn't find it.) No, I'm not "questioning the dev's judgement"... I'm just curious. =)
Tonio

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Fri Apr 02, 2004 5:55 pm

I'd commented about /zapvars possibly causing issues when passing params to your macro. Nevermind.. it still seems to work strangly enough.

Chaesar
orc pawn
orc pawn
Posts: 15
Joined: Mon Feb 23, 2004 1:28 pm

Post by Chaesar » Fri Apr 02, 2004 6:28 pm

I cannot find the thread atm, but the reason for the change was for those who use global variables in their /custombind commands. Lax had said that global variables didn't get cleared upon completion of macros, but later found that they did so he changed it.