Macro warnings from MQ2-20170908.zip

Need help running MacroQuest2? Ask your questions about how to get things to work on your computer.

Moderator: MacroQuest Developers

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

Macro warnings from MQ2-20170908.zip

Post by EqMule » Fri Sep 08, 2017 5:03 pm

I feel I should explain the changes a bit, but first of all, don't come here on patchday and say I didn't give you enough time to fix your macros.

Ok, now that that's settled, what's the deal with this?

Technical details:

Well, while implementing a new feature for calling functions within /if statements with eqholic (thanks)
I wanted to see how much of an impact this new functionality had on the performance.

Doing that I noticed a huge performance hog when mq2 deals with undeclared variables.

Ill give you an example:
Using the new functionality we can have a macro that looks like this:

Code: Select all

Sub Main
    /echo hi there
    /if (${AmIRiding}) {
         /echo yes I am
    } else {
        /echo no I'm not
    }
/return

Sub AmIRiding
    /if (${Me.Mount.ID}) {
        /return 1
    }
/return 0
As you can see this is all nice and well, until someone accidently adds a variable that's ALSO named AmIRiding
at that point the interpreter wont know if it should check the variable or call the function so we came up with the idea of just adding [] to functions.
so it now becomes

Code: Select all

Sub Main
    /echo hi there
    /if (${AmIRiding[]}) {
         /echo yes I am
    } else {
        /echo no I'm not
    }
/return

Sub AmIRiding
    /if (${Me.Mount.ID}) {
        /return 1
    }
/return 0
well that solved it, however, then a bigger problem arose, undeclared variables.
so in kiss (I'm using kiss because its 10000 lines of a beast and it has plenty of examples)
there was a line of code that said

Code: Select all

/if (${MyTargeID}) /dostuff
now as you can see that's misspelled, it should be MyTargetID
the problem with that is that the macro interpreter cant find that variable (its not declared)
and it would then send it on to the code that checks if its a function and then finally fail.

THAT whole process would be called OVER and OVER thousands of times, and mq2 would previously just silently take that and swallow it.
I ran cpu profiling on it and 40% or more of the cpu cycles where used up on trying to find undeclared and misspelled variables!

SO... THAT is the reason I HAD to make these changes, this has been going on for YEARS...

With this change, I no longer silently take it, now mq2 will display errors for these kind of things as well as logging it to a undeclared variables list.

That list can be displayed when a macro is running by doing /invoke ${Macro.Undeclared}

I know its a total PITA to go over every single macro and run them and fix these things by either declareing the variables or rename them if misspelled, but trust me once you get
it done, you will go from 40% cpu cycles dealing with them to 0 cycles, and your macros will run so much smoother and faster.
The increase in performance is night and day.

Ok so how to actually fix an error, first of all, you want to just run your macro and after a min or so click your hotkey where you have your /invoke ${Macro.Undeclared} line setup

then pause the macro and copy down the list, now go edit the macro, save start, rinse repeat until you get no more errors, then add a line #warning to the top of your macro and start it up again.

if you get any more errors it will warn u and pause the macro,

Here is an example warning and its fix:
Warning: ${ChaseAssit} is undeclared.
Fix: rename it to ${ChaseAssist}

Example 2:
ZDist in Sub Event_TooFar is undeclared
FIX: add /declare ZDist int local 0
to the beginning of that sub...

third problem is undeclared function parameters
for example we have this

Code: Select all

Sub DoStuff(string str1,string str2, string str3)
    ...
/return
now, if you call that with just /call DoStuff 1 2
and don't supply the third argument, EMPTY ARGS WILL ALWAYS DEFAULT TO NULL FROM NOW ON.
this break macros like Ninjaadvloot.inc which has a function:

Code: Select all

Sub SetupAdvLootVars(string ChangeIniFile)
now Kiss and other macros just always call it like /call SetupAdvLootVars
without supplying a parameter... lets see what that do:

Code: Select all

 /if (${ChangeIniFile.Length}) {
        /varset NinjaIniFile ${ChangeIniFile}
    }
as you now know, an EMPTY arg is now always "NULL" so the length will therefor be 4...
the fix is to change it to

Code: Select all

/if (${ChangeIniFile.NotEqual[NULL]}) {
        /varset NinjaIniFile ${ChangeIniFile}
    }
mkay... makes sense?

well I hope so, and ill be available both here and on skype to help out.
This is something that WILL take time, there will be blood sweat and tears I'm sure of it, but trust me in the end it will be worth it.

(this is also a first step to getting a fully fledged macro analyzer or maybe even a real time debugger for macros going in game. (think VisualStudio step over and break points...)
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.

exspes007
a hill giant
a hill giant
Posts: 193
Joined: Mon Oct 22, 2012 1:16 am

Re: Macro warnings from MQ2-20170908.zip

Post by exspes007 » Fri Sep 08, 2017 7:33 pm

why would a bind command, when issued, echo Starting Bind @ then do the routine then echo Ending Bind @

and thank you for the update. it has already helped me find a few typos.

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

Re: Macro warnings from MQ2-20170908.zip

Post by EqMule » Fri Sep 08, 2017 8:24 pm

It does that because this is a debug version and I want to make sure binds work.
When we are sure everything is working as intended and people have had time to report bugs I might remove the start and end text. I say might because I kinda like to know where the macro was at when the bind took control and ran...

If the start and end line number are ever different we have a bug and the stack is corrupted. (I think)
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.

FrankJScott
naggy
naggy
Posts: 2353
Joined: Sun Feb 19, 2023 7:11 am

Free Suggestions For Picking Semarjitu

Post by FrankJScott » Tue May 23, 2023 10:01 am

In reply to the guy talking about legitimate online casinos, trainwrecks gambling, make $100 a day sports betting, casino industry, I highly recommend this recommended Semarjitu tips alongside all get it twisted gamble, online casino real money paypal no deposit, lottery casino, play online slots for real money, semar jitu77, casino slot machines for sale, fliff sports betting, gambling machine, look at this top Semar Jitu forum alongside all online sweepstakes casino real money, best boxing betting sites, jai alai gambling, professional football betting, bet us casino, casinos like chumba and luckyland, online casino games list, sports betting bonus, try this top Semarjitu site for ignition gambling, legitimate online casinos, ufc gambling, free horse racing bets no deposit, best online casino no deposit sign up bonus, online sports betting sites, best bonus casinos, ncaa betting picks, not forgeting this excellent Semar Jitu forum and don't forget betting money, top football bets, sports betting and gambling, online gambling sites, horse racing betting sites, fanduel casino michigan, chumba casino free money, top casino sites, as well this best Semarjitu tips for paypal gambling, online betting games, best online casino real money no deposit, live blackjack online casino, nfl live betting, harry kakavas, bet in, states sports betting is legal, See More @ Handy Suggestions To Deciding On Slot Gates Of Olympus f252a1b

FrankJScott
naggy
naggy
Posts: 2353
Joined: Sun Feb 19, 2023 7:11 am

High Rated Product Site

Post by FrankJScott » Mon Dec 04, 2023 10:23 am

Please try Google before asking about Cool Product Site 1ac78_5

FrankJScott
naggy
naggy
Posts: 2353
Joined: Sun Feb 19, 2023 7:11 am

Best Buy Gold Coins In Prague Website

Post by FrankJScott » Wed Dec 06, 2023 5:24 pm

To the man talking about gold dollar price, pahlavi gold coin for sale, 2 gram gold biscuit price, ten dollar coin, sa investing gold, laxmi ganesh silver coin price, 4 gm gold coin price, buying gold near me, price of gold in rands, gold futures investing com, I highly suggest this top rated buy gold coins in Brno url or 20 dollar coin, 1914 gold sovereign, 50 dollar gold buffalo coin, best bullion companies, quarter gold price, buying price of gold today, gold company ira, gold and silver bullion, gold coin 22k, twenty dollar coin, alongside all this this post about buy gold coins in Prague info as well as small gold coin price, 10 kr coin, 2000 dollar coin, atocha gold coin, angel coin, 99999 gold, mining stocks etf, 1 krugerrand, maple leaf 1 oz, 1oz gold krugerrand price, not to mention this i loved this about buy gold coins in Brno link which is also great. Also, have a look at this excellent buy gold coins in Slovakia forum as well as rose gold coin, james madison gold coin, umayyad gold dinar, 1914 gold sovereign, buying gold, gold maple leaf, one oz of gold, gold silver coins, buy gold bullion near me, $20 gold double eagle, and don't forget this high rated buy gold coins in Brno info with franz joseph gold coin, gold etf, investing in gold bullion, best way to buy gold coins, we buy gold and silver, gold and silver investment companies, 2022 $50 gold buffalo tribute proof, 401k to gold ira, digital gold purchase, company ira gold, for good measure. Check more @ Recommended Savastano Cc Website 9f252a1

FrankJScott
naggy
naggy
Posts: 2353
Joined: Sun Feb 19, 2023 7:11 am

Awesome Safe Laser Blog

Post by FrankJScott » Thu Dec 14, 2023 7:24 pm

To the people inquiring about bemer rental, safe laser használata, safe laser ellenjavallat, bemer terápia, bemer bérlés, bemer device, I highly suggest this top rated lágylézer advice or bemer circulation therapy, bemer ágy, bemer terápia, safe laser használata, tissue laser, safe laser 150, alongside all this moved here for safe laser 500 info as well as bemer vascular therapy near me, bemer matrac, bemer for humans, bemer vascular therapy, safe laser kölcsönzés, the bemer pad, and don't forget this look at this on safe laser 500 details which is also great. Also, have a look at this had me going about safe laser 500 advice alongside all bemer health pad, safe laser 500 részletre, bemer treatment, bemer electromagnetic machine, bemer matrac, használt bemer készülék eladó, as well as this top rated sarkantyú kezelése házilag blog not to mention safe laser ellenjavallat, bemer for humans, bemer ágy, bemer vascular therapy, bemer electromagnetic, beamer healing device, alongside all top rated lágylézer url which is also worth a look. I also suggest this learn more here for haglund sarok info on top of soft laser therapy, bemer oxygen, bemer mat therapy near me, bemer magnetic mat, safe laser 150 ár, bemer terápia, alongside all this one-time offer for safe laser 500 url not to mention safe laser 1800, safe laser bérlés, bemer therapy for humans, safe laser 500 ár, bemer machine for healing, használt bemer készülék eladó, and don't forget continue reading this on sarkantyú kezelése url alongside all lágylézer kezelés, bemer microcirculation, bemer for humans, bemer vascular therapy, zúzódás tünetei, bemer health, which is also great. Finally, have a look at this redirected here for safe laser 500 info with bemer circulation device, safe laser 500 részletre, bemer therapy, bemer electromagnetic, safe laser 500 részletre, safe laser fülzúgás, for good measure. Check more @ New Business Massage Website 86b3ce3