Thread Tools Display Modes
03-22-18, 05:30 PM   #1
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Securely setting a global variable

I have the following code:

Lua Code:
  1. function PLAYER_LOGIN()
  2.  
  3.     BUFFS_PER_ROW=12
  4.     BUFF_MAX_DISPLAY=36
  5.     BUFF_HORIZ_SPACING=-1.25
  6.  
  7. end


This works great, however I get the following silly error when I try to rightclick buffs in combat:

Code:
Message: Note: AddOn attempted to call a protected function (CancelUnitBuff()) during combat lockdown.
Debug:
   [C]: CancelUnitBuff()
   ..\FrameXML\BuffFrame.lua:280: BuffButton_OnClick()
   [string "*:OnClick"]:1:
      [string "*:OnClick"]:1

I'm not altering these in combat. The values do not change beyond login. Is there a secure way to change these three variables?

I am not interested in any buff addons. I just want to change these three global variables once each session.
  Reply With Quote
03-23-18, 10:07 AM   #2
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Doesn't matter if you change them in combat or not, you've still tainted these globals.
If the stuff you want to move around isn't secure, you should probably hook the functions that control the layout and alter the layout that way.
__________________
  Reply With Quote
03-23-18, 02:46 PM   #3
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
I don’t think there’s any functions tied to those variables. They’re directly set and used in BuffFrame.lua. Thanks for your help anyways.
  Reply With Quote
03-23-18, 03:07 PM   #4
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Originally Posted by Kanegasi View Post
I don’t think there’s any functions tied to those variables.
These are both globals you can hook and apply your changes afterwards.
You could just copy the contents of these functions into your hook and replace the globals used with your own locals.
Lua Code:
  1. BuffFrame_UpdateAllBuffAnchors
  2. DebuffButton_UpdateAnchors
__________________
  Reply With Quote
03-23-18, 06:50 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
ShinyBuffs edits BUFFS_PER_ROW with no issue. So it may be one of the other two. Have you tried narrowing down which?
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
03-24-18, 12:38 PM   #6
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Originally Posted by Seerah View Post
ShinyBuffs edits BUFFS_PER_ROW with no issue. So it may be one of the other two. Have you tried narrowing down which?
I didn't think it would just be one or two of them. I immediately assumed it was the spacing one since it's used in buff:SetPoint. To my surprise, the max display is what's causing the rightclick block, and I have no idea why.

Here's all five mentions of the variable in the entire extract:

Code:
..Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua (3 hits)
	Line 492: 		for i = 1, BUFF_MAX_DISPLAY do
	Line 513: 		for i = 1, BUFF_MAX_DISPLAY do
	Line 540: 		for i = buffIndex, BUFF_MAX_DISPLAY do
..Interface\FrameXML\BuffFrame.lua (2 hits)
	Line 7: BUFF_MAX_DISPLAY = 32;
	Line 90: 	for i=1, BUFF_MAX_DISPLAY do
I'm going to assume the nameplate code is causing a taint just by proxy. I originally wanted three even rows of 12, looks like I'll have to settle with three rows of 11 with one spot missing. Getting to max buffs is super rare anyways.
  Reply With Quote
03-24-18, 01:32 PM   #7
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Seerah View Post
ShinyBuffs edits BUFFS_PER_ROW with no issue. So it may be one of the other two. Have you tried narrowing down which?
Just because you can override their values that doesn't mean that you should. As you can see you did nothing wrong here and the game still locks you down.

If you override SECOND_ONELETTER_ABBR, every time any kind of cooldown object gets updated in your UI, a global taint will run by the game, you can guess the overhead that could cause.
See related: http://www.wowinterface.com/download....html#comments

Last edited by Resike : 03-25-18 at 03:26 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Securely setting a global variable

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off