• You've discovered RedGuides, an EverQuest multi-boxing and scripting community 🧙‍♀️⚙️. We want you to play several EQ characters at once, come join us and say hello! 👋

  • A TLP without truebox has thawed (Very Vanilla ready)
    Frostreaver

Bug - How can we log the LastCommand prior to an exit or crash?

Redbot

💻❤️
Moderator
Joined
Oct 15, 2004
RedCents
104,058¢
Pronouns
He/Him
@Denethor asked me about logging the last command from a macro, and I'm a little stumped on how this can be done. Any solution we come up with just crashes.

Here's a macro replicating the crash. This happens with both /mqlog and /mlog
[CODE title="TestExit.mac"]sub Main
/declare blnMacroComplete int outer 0
/echo TestExit Macro
/echo Ending in 3 sec...
/delay 1s
/echo Ending in 2 sec...
/delay 1s
/echo Ending in 1 sec...
/delay 1s

:OnExit
/if ( !${blnMacroComplete} && !${MacroQuest.LastCommand.Find[/end]} && !${MacroQuest.LastCommand.Find[/camp]}) {
/echo Exiting
/mqlog Exiting
/echo LastCMD: ${MacroQuest.LastCommand}
/mqlog LastCMD: ${MacroQuest.LastCommand}
}
/return
[/CODE]

And here's what appears in the Logs/charname_server.log file:

Code:
[2020/06/14 16:51:46] [MQ2] TestExit Macro

[2020/06/14 16:51:46] [MQ2] Ending in 3 sec...

[2020/06/14 16:51:47] [MQ2] Ending in 2 sec...

[2020/06/14 16:51:48] [MQ2] Ending in 1 sec...

[2020/06/14 16:51:49] [MQ2] Exiting

[2020/06/14 16:51:49] [MQ2] LastCMD: /mqlog Exiting

[2020/06/14 16:51:49] Syntax Error: /mqlog LastCMD: ${MacroQuest.LastCommand} Line:16 in testexit.macNewLength 40 was greater than BufferSize - addrlen 29 in ParseMacroData, did you try to read data that exceeds 2048 from your macro?
 
I thought the OnExit was only called when the /end was called?

Anything included after that label will be called whenever an /endmacro
command is issued. To use this feature, the label must be at the end
of your 'Sub Main' function and end with a /return. Please note that
this is NOT required of macros, so no macros will have to be altered
unless you wish to take advantage of this feature. (See my posting
on the messageboards for an example of how to use this.)
 
it is a recursion issue when last command is called twice back to back
 
Okay, so store it to a variable and compare/echo that variable. I can do that for a work around. Trying to wrap my head around the explanation (I understand recursion as a concept, I'm not understanding how I'm triggering it yet. Will re-read when I have more time to focus.)


Regardless, be good if there was an exception handler / catch for that, so it doesn't cause a CTD.
 
/echo LastCMD: ${MacroQuest.LastCommand}
/mqlog LastCMD: ${MacroQuest.LastCommand}


When you mqlog the LastCMD it is evaluated as:
/mqlog LastCMD: /echo LastCMD: ${MacroQuest.LastCommand}

So when you parse that it is:
/mqlog LastCMD: /echo LastCMD: /echo LastCMD: ${MacroQuest.LastCommand}

so when you pare that it is:
/mqlog LastCMD: /echo LastCMD: /echo LastCMD: /echo LastCMD: ${MacroQuest.LastCommand}

etc.
 
Doing something recursively usually has a base case, or a reason to stop doing the recursive function such as each new call to itself having altered information being passed to it. There are problems that can be solved with recursive function calls, but it can also be a recipe for disaster. If you have a recursive call that infinitely calls itself, such as in Knightly description you end up with stack overflow. Each new call is reserving some amount of space on the stack. The stack quickly gets filled with the calls and you run out of space on the stack to store information, and then everything goes down in fire and flames.

In the case of MacroQuest.LastCommand calling itself, it becomes infinite recursion. Storing the information to a variable and then using that variable for the comparison is the way I had ultimately decided was a work around until a fix was generated for it. In a way, it's probably the better way to do it anyway if you plan to call it multiple times. Multiple times can be misleading. For example ${Select[${MacroQuest.LastCommand}, /end, /endm, /endmac, /endmacro]} would be checking ${MacroQuest.LastCommand} for each one of the ${Select's entries. No differently than doing it as a bunch of /if (${MacroQuest.LastCommand.Equal[/end]} || ${MacroQuest.LastCommand.Equal[/endm]} etc etc)
 
Bug - How can we log the LastCommand prior to an exit or crash?

Users who are viewing this thread

Back
Top
Cart