• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Optimizer and ExecuteFunc

Status
Not open for further replies.
Level 2
Joined
Feb 8, 2011
Messages
31
When using Vexorian's Wc3 Map Optimizer, when does the use of ExecuteFunc bug?
I've not had any problems yet, but I often read that this program will break ExecuteFunc. Does anybody have an answer for this?
 
When using Vexorian's Wc3 Map Optimizer, when does the use of ExecuteFunc bug?
I've not had any problems yet, but I often read that this program will break ExecuteFunc. Does anybody have an answer for this?

When the optimizer shortens/changes variable/function names, it doesn't take into account ExecuteFunc() and TriggerRegisterVariableEvent(). (or so I've heard) The fix is to either not use those functions, or to uncheck "Compress names". (I think)

I've never tried it, but you might be able to disable the protection-features, and fix any of the executefunc()/variable event changes. (while your map is still unprotected, but optimized) And then after that, you can add the protection features. (disable the script optimization/name compression)

Overall, I recommend that you make several backups of your map and see what works.
 
Level 2
Joined
Feb 8, 2011
Messages
31
The Optimizer doesn't seem to break ExecuteFunc whenever it's used though (from my experience) no matter what options I choose. I assumed then that ExecuteFunc must break under some special condition(s).

Just a few examples of a part of an optimized script:

Library initialization functions are renamed:
JASS:
call ExecuteFunc("IA")
call ExecuteFunc("uE")
call ExecuteFunc("EX")
call ExecuteFunc("bO")
call ExecuteFunc("FO")

All variables used for it are also changed to the correct names:
JASS:
set Ni[0]="JR"
set Ni[1]="lR"
set Ni[2]="mR"
set Ni[3]="pR"
set Ni[4]="qR"
set Ni[5]="sR"
set Ni[6]="tR"
set Ni[7]="uR"
set Ni[8]="WR"
set Ni[9]="YR"
set Ni[10]="ZR"
set Ni[11]="eI"
set Ni[12]="rI"
set Ni[13]="aI"
set Ni[14]="VI"
set Ni[15]="XI"
set Ni[16]="RI"

Everything is correct.
 
Level 2
Joined
Feb 8, 2011
Messages
31
I did some testing, and I was surprised. I thought the optimizer renamed everything to be smaller which would break string concentration with ExecuteFunc. The optimizer never even changed the function name of the function I was using for ExecuteFunc as a concentrated string. I guess that's because the optimizer never saw it being used. In Test 2 I set a string to the function name which broke ExecuteFunc. I'm also aware that I messed up the name of my global string when I set it to the function name. I don't think this would alter the result when dealing with this test.

@Troll-Brain, Your example on that post shouldn't break unless MyF1 is being used somewhere else (or unless a tool is used to delete all "unused" functions):
JASS:
function MyF1 // ...

endfunction

function TheCodeInsideItWillBeBreakedByWc3MapOptimizer takes nothing returns nothing
   local integer i = 0

   call ExecuteFunc("MyF"+"1")
   set i = i+1
   call ExecuteFunc("MyF" + I2S(i))
endfunction


Test 1:
JASS:
globals
integer test1
integer test2
string test3
force test4
location test5
real test6
real test7
endglobals
function Init1 takes nothing returns nothing
local integer i
local force f
local real r
set test1 = 0
set test2 = 0
endfunction
function Init2 takes nothing returns nothing
local integer i
local force f
local real r
set test3 = ""
set test4 = CreateForce()
endfunction
function Testfunction takes nothing returns nothing
local integer i
local force f
local real r
set test6 = 0
set test7 = 0
set test5 = Location(test6,test7)
endfunction
function main takes nothing returns nothing
call Init1()
call ExecuteFunc("Init2")
call ExecuteFunc("Testfunctio"+"n")
endfunction
function config takes nothing returns nothing
call main()
endfunction

JASS:
globals
integer e
integer x
string o
force a
location n
real V
real E
endglobals
function m takes nothing returns nothing
local integer i
local force f
local real r
set o=""
set a=CreateForce()
endfunction
function Testfunction takes nothing returns nothing
local integer i
local force f
local real r
set V=0
set E=0
set n=Location(V,E)
endfunction
function main takes nothing returns nothing
local integer i
local force f
local real r
set e=0
set x=0
call ExecuteFunc("m")
call ExecuteFunc("Testfunctio"+"n")
endfunction
function config takes nothing returns nothing
local integer i
local force f
local real r
set e=0
set x=0
call ExecuteFunc("m")
call ExecuteFunc("Testfunctio"+"n")
endfunction

Test 2:
JASS:
globals
string teststring
endglobals
function Testfunction takes nothing returns nothing
local integer i
local force f
local real r
endfunction
function main takes nothing returns nothing
set s = "Testfunction"
call ExecuteFunc("Testfunctio"+"n")
endfunction
function config takes nothing returns nothing
call main()
endfunction

JASS:
globals
group n=null
endglobals
function H takes nothing returns nothing
local integer i
local force f
local real r
endfunction
function main takes nothing returns nothing
set s="H"
call ExecuteFunc("Testfunctio"+"n")
endfunction
function config takes nothing returns nothing
set s="H"
call ExecuteFunc("Testfunctio"+"n")
endfunction
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
I didn't know that wc3mapotimizer inlined functions like Init1 of Test1.

Test 2

Woot ?!

JASS:
globals
string teststring
endglobals

becomes ?!

JASS:
globals
group n=null
endglobals

And you don't use any group in the code ...

So if we forgot this freaky bug, we can conlude that wc3mapoptimizer doesn't handle string concatenation with constant strings.
And he doesn't reduce functions name which are considered to be not used.
And if you use a constant string which is equal to the name of a function, it considers that this function is being used and both reduce the name of the function and the string.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
I don't get why people keep complaining about optimizer, Vexorian is not here and it is a great tool (which doesn't like variable events if you tick compress names) no matter what they say.

Actually they can complain about these things of course, but what I don't like is "optimizer is buggy", "don't use it", "it will break your map" etc...
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
I don't get why people keep complaining about optimizer, Vexorian is not here and it is a great tool

Dude, it's the wrong thread it's indeed the first wc3mapoptimizer related thread that i haven't seen any complains and trolls.
But i'm totally with you, i'm wondering how wc3 modding would be without Vexorian, he is just awesome.

(which doesn't like variable events if you tick compress names) no matter what they say.

Interesting, you have the most-up-to-date version of wc3mapoptimizer ?
But honestly i think you are wrong, just because of what Bribe said, in fact every public or private real (vJass) will be breaked by wc3mapoptimizer, according to him.
I didn't test it myself but i believe enough in Bribe.

Actually they can complain about these things of course, but what I don't like is "optimizer is buggy", "don't use it", "it will break your map" etc...

Sure wc3maptimizer isn't perfect but it's still pretty good and at very least it exists.
 
Status
Not open for further replies.
Top