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:
attachment.php

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"

attachment.php

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.

attachment.php

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.

attachment.php

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.

attachment.php

attachment.php

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

  • Tutorial 6.jpg
    Tutorial 6.jpg
    154.3 KB · Views: 856
  • Tutorial 5.jpg
    Tutorial 5.jpg
    208.2 KB · Views: 876
  • Tutorial 4.jpg
    Tutorial 4.jpg
    156.8 KB · Views: 831
  • Tutorial 3.jpg
    Tutorial 3.jpg
    17 KB · Views: 825
  • Tutorial 2.jpg
    Tutorial 2.jpg
    15.7 KB · Views: 816
  • Tutorial 1.jpg
    Tutorial 1.jpg
    330.1 KB · Views: 851

luorax

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

Laiev

Hey Listen!!
Reaction score
188
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
84
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
84
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.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top