Tutorial How to get the "Compress Names" optimizer function work

luorax

Invasion in Duskwood
Reaction score
67
Introduction
Short variable names are not only faster, but reduce the script's total size. It's a known fact. But nowadays many people write their submissed systems/snippets - even the complicited ones - that takes more time understing, than writing, because of the super-annoying short names. Their reason(/excuse): The "Compress Names" function of Vexorian's optimizer is broken, and as said above, it's faster this way. Well, this little tutorial will show you how you can get it work, so that this annoying habit can finally go to an end.

Tools Needed
  1. Wc3mapoptimizer
  2. Ladik's MPQ Editor
  3. Notepad++ (Optional)

Let's Begin!

1, First of all, we need a map. Open the optimizer, browse the map, and set it up according to your liking. I'll make it like this:

2, Click "Save optimized as..." and save it. This will optimize everything and create two files: the optimized map, and the script file. Go and rename it immediately to "war3map.j"


3, Open the generated script file. Natives must be directly under global declaration, after the keyword [ljass]endglobals[/ljass]. The optimizer generates some garbage functions and places them inbetween the two of them; locate all the custom declared natives and move them where they belong.


4, Open Ladik's awesome MPQ editor. We know how big our script file is; sort files by file size, locate the script file, and delete it. If you're not sure it's the right file, open it by double-clicking on it.


5, Go to Operations -> Add File(S), or press Ctrl+A. Locate our fixed script file, and import it. When the window pops up, select "Compress+Encrypt" and "Zlib" compression. Then go File -> Close all MPQ's.



6, Open your WarCraft 3 and test it. It should work by now.


ExecuteFunc/TriggerRegisterVariableEvent natives
Those two natives have a string parameter; one of them is a function name, the other one is a variable name. If you pass a concatenated string, the optimizer will just ignore it. It can also be fixed by editing the "war3map.j" script file, when fixing the native bug, but you have to go through the entire file and find all these function calls, plus their arguments' shortened names. It's hard and time-consuming.
Fixing it is simple; you have many options:
  • Don't use those natives; use either JASSHelper's [ljass].evaluate/.execute[/ljass] functions
  • Evaluate triggers manually.
  • Use this snippet.

Credits
  • BBQ, for revealing why natives break maps
  • Vexorian & Ladik, for their tools
 

Attachments

luorax

Invasion in Duskwood
Reaction score
67
Updated; now it mentions[ljass]ExecuteFunc[/ljass]/[ljass]TriggerRegisterVariableEvent[/ljass].
 

Laiev

Hey Listen!!
Reaction score
187
Attach the images here and use it, it don't work using the attachment of Hive.
 

luorax

Invasion in Duskwood
Reaction score
67
Well, they worked fine for me - but okay, why not? I changed it.
 

Nestharus

o-o
Reaction score
83
This is no longer enough to get compressed names to work with the latest map optimizer. Compressed names for natives now work, but the values for constants don't work... furthermore, the optimizer now adds tons of useless bj code.
 

Bribe

vJass errors are legion
Reaction score
67
For future readers, the reason for optimizer not inlining some constant real values was given by Vexorian and it's working as intended.

Also, Vexorian fixed the script so that it recognizes if you don't want to inline BJ's, in which case it doesn't inline things like InitBlizzard.

The only thing the optimizer doesn't do (and no optimizer could reasonably predict), is if you use non-constant strings with ExecuteFunc (for example function names concatenated with I2S). However, there is a half dozen better ways to do this and that's also a ridiculously slow way to execute a function.
 

Nestharus

o-o
Reaction score
83
So will it compress 0 function names?
The only thing the optimizer doesn't do (and no optimizer could reasonably predict), is if you use non-constant strings with ExecuteFunc (for example function names concatenated with I2S). However, there is a half dozen better ways to do this and that's also a ridiculously slow way to execute a function.
Because my save/load stuff does use ExecuteFunc with non constant function names >.<.
 

Bribe

vJass errors are legion
Reaction score
67
Looks like when the optimizer recognizes non-constant things, that it just doesn't compress names of unknown functions. For example, it shortened normal variable names and jasshelper_initstructs1203954385489 but not functions that the ExecuteFunc MIGHT be calling:

JASS:
globals
real v=0
endglobals
function InitGlobals takes nothing returns nothing
endfunction
function Actions4 takes nothing returns nothing
endfunction
function InitTrig_Untitled_Trigger_004 takes nothing returns nothing
call ExecuteFunc(&quot;Actions&quot;+I2S(4))
endfunction
function InitCustomTeams takes nothing returns nothing
call SetPlayerTeam(Player(0),0)
endfunction
function main takes nothing returns nothing
call SetCameraBounds(-1280.+GetCameraMargin(CAMERA_MARGIN_LEFT),-3584.+GetCameraMargin(CAMERA_MARGIN_BOTTOM),1280.-GetCameraMargin(CAMERA_MARGIN_RIGHT),3072.-GetCameraMargin(CAMERA_MARGIN_TOP),-1280.+GetCameraMargin(CAMERA_MARGIN_LEFT),3072.-GetCameraMargin(CAMERA_MARGIN_TOP),1280.-GetCameraMargin(CAMERA_MARGIN_RIGHT),-3584.+GetCameraMargin(CAMERA_MARGIN_BOTTOM))
call SetDayNightModels(&quot;Environment\\DNC\\DNCFelwood\\DNCFelwoodTerrain\\DNCFelwoodTerrain.mdl&quot;,&quot;Environment\\DNC\\DNCFelwood\\DNCFelwoodUnit\\DNCFelwoodUnit.mdl&quot;)
call NewSoundEnvironment(&quot;Default&quot;)
call SetAmbientDaySound(&quot;FelwoodDay&quot;)
call SetAmbientNightSound(&quot;FelwoodNight&quot;)
call SetMapMusic(&quot;Music&quot;,true,0)
call InitBlizzard()
call ExecuteFunc(&quot;e&quot;)
set v=0
call ExecuteFunc(&quot;Actions&quot;+I2S(4))
endfunction
function config takes nothing returns nothing
call SetMapName(&quot;TRIGSTR_001&quot;)
call SetMapDescription(&quot;TRIGSTR_003&quot;)
call SetPlayers(1)
call SetTeams(1)
call SetGamePlacement(MAP_PLACEMENT_USE_MAP_SETTINGS)
call DefineStartLocation(0,-128.,.0)
call SetPlayerStartLocation(Player(0),0)
call SetPlayerColor(Player(0),ConvertPlayerColor(0))
call SetPlayerRacePreference(Player(0),RACE_PREF_HUMAN)
call SetPlayerRaceSelectable(Player(0),true)
call SetPlayerController(Player(0),MAP_CONTROL_USER)
call SetPlayerSlotAvailable(Player(0),MAP_CONTROL_USER)
call InitGenericPlayerSlots()
endfunction
function e takes nothing returns nothing
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    Hope you have safe travels my friend!
    +1
  • vypur85 vypur85:
    Wow spring time in Japan is awesome. Enjoy!
  • The Helper The Helper:
    Hopefully it will be more pleasure than work
  • vypur85 vypur85:
    Recently tried out ChatGPT about WE triggering. Wow it's capable of giving a somewhat legitimate response.
  • The Helper The Helper:
    I am sure it has read all the info on the forums here
  • The Helper The Helper:
    i think triggering is just scripting and chatgpt is real good at code
  • vypur85 vypur85:
    Yeah I suppose so. It's interesting how it can explain in so much detail.
  • vypur85 vypur85:
    But yet it won't work.
  • The Helper The Helper:
    it does a bad ass job doing excel vba code it has leveled me up at my job when I deal with excel that is for sure
  • vypur85 vypur85:
    Nice! I love Excel coding as well. Has always been using Google to help me. Maybe I'll use ChatGPT next time when I need it.
  • The Helper The Helper:
    yeah whatever it puts out even if it is not perfect I can fix it and the latest version of chatgpt can create websites from pictures it will not be long until it can do that with almost all the tools
    +1
  • The Helper The Helper:
    These new Chat AI programs are going to change everything everyone better Buckle the Fuck Up!
  • The Helper The Helper:
    oh and Happy Tuesday Evening! :)
    +1
  • jonas jonas:
    Im worried they'll change things for worse
  • jonas jonas:
    A lot more low quality content, a lot more half-baked stuff.
  • jonas jonas:
    If you're good enough to spot the mistakes of the answers you don't need it in the first place. If you aren't good enough, you're gonna rely on some half-correct stuff
  • The Helper The Helper:
    the earlier AI is and has been used extensively for publishing news and other content for a while now
  • jonas jonas:
    I used to be active on quora, it's now flooded with extremely similar, superficial answers that often miss the point of the question
  • N NJJ:
    hi
  • N NJJ:
    Hello, gathering all my old accounts… :)
    +1
  • The Helper The Helper:
    by all means gather it all up!
  • The Helper The Helper:
    Happy Thursday!
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

    The Helper Discord

    Members online

    No members online now.

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top