Jasshelper 2011-12-19

Status
Not open for further replies.
Add some docs on the new preprocessor directives (#bigdef for example).


It would be really nice if you could nest macro calls

JASS:
//! textmacro boo
    //! runtextmacro hi()
//! endtextmacro
//! textmacro hi
//! endtextmacro

modules with parameters (something vex has been planning but has yet to do).
module Init takes ho, boo, yo
implement Init(x, y, z)


Also, it would be excellent if you assumed that all code inside of an external block was Lua so that we wouldn't need the mass //! i anymore. Typing that all out is annoying as hell, so please.


After those, I think this tool'll prob be good to go ^)^.


Also, it'd be cool if the vjass optimizer removed inlined global constants ^)^.
 
Level 6
Joined
Jun 16, 2007
Messages
235
Add some docs on the new preprocessor directives (#bigdef for example).
CPP preprocessor has been removed due to lack of public support.

It would be really nice if you could nest macro calls
No it would not, it would be ugly and dangerous. This will never happen.

modules with parameters (something vex has been planning but has yet to do).
module Init takes ho, boo, yo
implement Init(x, y, z)
Useless.

Also, it would be excellent if you assumed that all code inside of an external block was Lua so that we wouldn't need the mass //! i anymore. Typing that all out is annoying as hell, so please.
Learn to use notepad++ regular expressions.

Also, it'd be cool if the vjass optimizer removed inlined global constants ^)^.
This is a job for optimizer not for the compiler.
It is much more useful to see names in map script than random numbers when some error happens.

================
The thing I have on schedule next is optimizing function interfaces.
 
uh... Vexorian has been planning modules that take arguments this whole time and has yet to do it. It's really not useless at all >.>. There have been many cases where modules with args would have helped me a lot.

No it would not, it would be ugly and dangerous. This will never happen.

About as ugly and dangerous as recursive function calling?
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
The function InitGlobals for GUI globals variables is called after the vJass initalizers in the function main.
I don't see a good reason for it.
Don't take me wrong, i have not used GUI since years, and i don't like it since the same time.
But you are unable to use a GUI global value inside a vJass initializer, since its value is not currently defined in such initializers, and will be erased when InitGlobals will be called.

The only reason i see with it so far, it is for fuck up GUI users.
Indeed, just leave some global array with index max 8192 in the variable editor (one or two is probably enough) and then all GUI triggers will never be created, because limit op will be reached before GUI initializers calls, when InitGlobals will fire.

If we want to keep this kind of "feature", we still have the hook DoNothing.
 
Level 6
Joined
Jun 16, 2007
Messages
235
About as ugly and dangerous as recursive function calling?
Nice try, but I don't hook that easily.
The comparison is without meaning and you know it.

The function InitGlobals for GUI globals variables is called after the vJass initalizers in the function main.
I don't see a good reason for it.
...
But you are unable to use a GUI global value inside a vJass initializer
This never crossed my mind because I don't use GUI variables.
GUI mappers are valid users of jasshelper, I have no intention of breaking anything for them by changing things without good reason.
This will go under the "investigate" in the TODO list.

PS: if you really need to set GUI variables in scope or library initializers you can always set them after TriggerSleepAction(0.0)
 
Level 16
Joined
Aug 7, 2009
Messages
1,406
Nice compiler, however here's one thing: in larger maps, JH quite often pops up a "memory exhausted" error message - I tend to use huge lua blocks to generate item objects (which comes as an item + an abil with multiple level). So, do you have any plans for it?

Also, you've fixed the init order - does it mean if I replace my old JH with this one I'll have to rewrite everything, or old things would still work? (Soz for being lame, I'm kind of tired right now, it's too late here >.<)
 
Level 6
Joined
Jun 16, 2007
Messages
235
Fixed SpellEvent library issue 2012-02-07
Once again watermelon_1234 saves the day. :)

Also, you've fixed the init order - does it mean if I replace my old JH with this one I'll have to rewrite everything, or old things would still work?

I had many fears when I started working on init order that it would break everything, but as it turns out 99% of the maps will not need any changes.

If there is anything you need to rewrite jasshelper compiler will tell you about it, and it is only renaming jobs so it is all easily done in 2 min.
 
Level 6
Joined
Jun 16, 2007
Messages
235
//! import "luajass.WmW_Masters.j"

considering imports don't work, I can't use this -.-, soooo gg
Nice of you to report it.

and you can't read GUI vars from JASS...
It is only in Init triggers, in spells you can use them all you want.
Blame Vex for this, not me. (I am trying to find a solution atm)

and the entire main function is now broken.. it gave me undeclared function InitSounds()... seriously?
This is an example of a bad bug report.
Please post a demo map with a bug.


EDIT:
It seems all your bugs are chained to be bad //! import
working on a fix....
 
The map I put it into contains masses of code, so I don't know what caused it ; P. All I know is that main doesn't work, lol.

It is only in Init triggers, in spells you can use them all you want.
Blame Vex for this, not me. (I am trying to find a solution atm)

hm? I couldn't read them inside of an onInit method for a vjass struct? they work in official jasshelper just fine?


lol, one of the ways I used to help cjass peeps find a lot of bugs is that I'd try to compile my huge system library with it to see if any bugs popped up : P. The map I put this into doesn't have as many resources in it as my system lib map does ^)^, but it still found quite a few bugs ;p.
 
Level 6
Joined
Jun 16, 2007
Messages
235
they work in official jasshelper just fine?
No, they don't.

jasshelper 0.A.2.B
JASS:
//===========================================================================
function main takes nothing returns nothing
    call SetCameraBounds(- 1280.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), - 1536.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM), 1280.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), 1024.0 - GetCameraMargin(CAMERA_MARGIN_TOP), - 1280.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), 1024.0 - GetCameraMargin(CAMERA_MARGIN_TOP), 1280.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), - 1536.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM))
    call SetDayNightModels("Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl", "Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdl")
    call NewSoundEnvironment("Default")
    call SetAmbientDaySound("LordaeronSummerDay")
    call SetAmbientNightSound("LordaeronSummerNight")
    call SetMapMusic("Music", true, 0)
    call InitBlizzard()

call ExecuteFunc("jasshelper__initstructs15888592")  // <----------<<


    call InitGlobals()    // <----------<<
    call InitCustomTriggers()
    call RunInitializationTriggers()

endfunction

current jasshelper:
JASS:
//===========================================================================
function main takes nothing returns nothing
    call SetCameraBounds(- 1280.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), - 1536.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM), 1280.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), 1024.0 - GetCameraMargin(CAMERA_MARGIN_TOP), - 1280.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), 1024.0 - GetCameraMargin(CAMERA_MARGIN_TOP), 1280.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), - 1536.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM))
    call SetDayNightModels("Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl", "Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdl")
    call NewSoundEnvironment("Default")
    call SetAmbientDaySound("LordaeronSummerDay")
    call SetAmbientNightSound("LordaeronSummerNight")
    call SetMapMusic("Music", true, 0)
    call InitBlizzard()

call ExecuteFunc("jasshelper__initstructs1260") // <----------<<

    call InitGlobals() // <----------<<
    call InitCustomTriggers()
    call RunInitializationTriggers()

endfunction

GUI variables were always initialized after jass stuff.
I could change that but I am not yet sure if I should.

Like I said earlier all your bugs are just 1 bug - from error in importing section.
If map has no //! import everything works just fine.

While you wait for a fix you might be interested in this:
http://www.wc3c.net/showthread.php?p=1133730
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
The fix for being able to use GUI variables in jass initializer is easy, call InitGlobals before vJass initializers, and not the opposite like actually.

But you will still not safely be able to use a GUI variable like that :

JASS:
globals
    integer I = udg...
endglobals

Because if i remember correctly, the "default" value given in the variable editor is applied only when InitGlobals is called, that's how the variable editor handle them.

It makes sense for a "sized" array, but not really for not array variables.
Even if some native functions don't work or even make wc3 crash, if used in a global definition, like GetLocalPlayer (but i call it a bug)

Also for not array variables, even if the user specify a default value in the variable editor, a "null" value will be given in the global definition according to the variablle type, and then the default value will be applied inside InitGlobals:

Assuming udg_Bool default value is "true" :

JASS:
globals
    boolean udg_Bool = false
...
endglobals

function InitGlobals takes nothing returns nothing
    set udg_Bool = true
...
endfunction

I have not tested it since years though, that's just memories.
 
Level 6
Joined
Jun 16, 2007
Messages
235
2012-02-07b
Fixed //! import directive

Now about InitGlobals:

When you use GUI variables editor to declare:
1. integer x with value 123
2. array a of length 8190

this is what happens:

JASS:
function InitGlobals takes nothing returns nothing
    local integer i= 0
    set udg_x=123
    set i=0
    loop
        exitwhen ( i > 8190 )
        set udg_a[i]=0
        set i=i + 1
    endloop

endfunction

It is obvious why this is idiotic but there is nothing I can do here because that is code generated by blizzard not by jasshelper.

If I call this before jass initializers there is a big chance that the game will crash due to OP overflow.

I would need to wrap this in ExecuteFunc but than it could crash silently and you would never get an error report.

I am still undecided what to do here....
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Are you sure you don't want some GUI adepts crying about that "your" jasshelper disable all trigger stuff ?

Seriously, i don't see something wrong with calling InitGlobals before vJass initializers, if it is through an ExecuteFunc, or whatever else which creates a new thread.
I mean even if InitGlobals reach the limit op, the main function won't be broken, and you will be able to use GUI variables in vJass initializers, which is not really possible for now.

For the silent crash of InitGlobals, instead of ExecuteFunc you can TriggerEvaluate it and get the returned boolean, to display a warning error in game, in debug mode.
Or still use ExecuteFunc but with a global boolean at the end.
(you set it to false in the global definition, and true in the last line of InitGlobals.
After the InitGlobals call, if the variable is true then InitGlobals didn't crash, else it did and the variable is equal to false)
Or implement a built-in limit op checker :p (joke ofc)

Now, if i'm missing something, in case that InitGlobals can still crash the whole main function, that is not the same thing.
 
Last edited:
Level 6
Joined
Jun 16, 2007
Messages
235
I assume that GUI users know about global array initialization problems or their maps would crash all the time with or without jasshelper.

As for jass people wanting to use GUI globals in onInit methods I guess I could call InitGlobals before jasshelper inits.
But how many jassers really use GUI global variables?

I am inclined to leave all this as it is.
Jasshelper called it after structs for years now and there were no big public outcries.

As it is right now, this "issue" is at the bottom of my priority list.
 
Level 6
Joined
Jun 16, 2007
Messages
235
I'm using preplaced rects (and a few buildings) too, and with the old JASSHelper (0.A.2.B). A one-shot timer with "0." expiration time works perfectly for me.

Nestharus is just trolling, ignore him.
I already told him about 0.0 solution earlier in the thread.
 
I'm not trolling, I just don't think you should have to do the TimerStart thing. I know I don't have to do it with vex's jasshelper.

JASS:
library Paths uses Path, Testing
    struct Paths extends array
        private static Path array leftp
        private static Path array rightp
        static method operator [] takes integer pid returns thistype
            return pid/3
        endmethod
        method operator left takes nothing returns Path
            return leftp[this]
        endmethod
        method operator right takes nothing returns Path
            return rightp[this]
        endmethod
        private static method onInit takes nothing returns nothing
            local Path topLeft = Path.create()
            local Path topRight = Path.create()
            local Path bottomLeft = Path.create()
            local Path bottomRight = Path.create()
            
            set leftp[0] = bottomLeft
            set rightp[0] = bottomRight
            set leftp[1] = topLeft
            set rightp[1] = topRight
            
            call topLeft.add(gg_rct_Middle_Center_Top_Left)
            call topLeft.add(gg_rct_Middle_Top_Left)
            call topLeft.add(gg_rct_Top_Left)
            call topLeft.add(gg_rct_Top_Center)
            call topLeft.add(gg_rct_Load_Top)
            
            call topRight.add(gg_rct_Middle_Center_Top_Right)
            call topRight.add(gg_rct_Middle_Top_Right)
            call topRight.add(gg_rct_Top_Right)
            call topRight.add(gg_rct_Top_Center)
            call topRight.add(gg_rct_Load_Top)
            
            call bottomLeft.add(gg_rct_Middle_Center_Bottom_Left)
            call bottomLeft.add(gg_rct_Middle_Bottom_Left)
            call bottomLeft.add(gg_rct_Bottom_Left)
            call bottomLeft.add(gg_rct_Bottom_Center)
            call bottomLeft.add(gg_rct_Load_Bottom)
            
            call bottomRight.add(gg_rct_Middle_Center_Bottom_Right)
            call bottomRight.add(gg_rct_Middle_Bottom_Right)
            call bottomRight.add(gg_rct_Bottom_Right)
            call bottomRight.add(gg_rct_Bottom_Center)
            call bottomRight.add(gg_rct_Load_Bottom)
        endmethod
    endstruct
endlibrary

That is the code that throws a million syntax errors in yours (undefined variables).



Why are you breaking functionality?
 
Level 6
Joined
Jun 16, 2007
Messages
235
Preplaced rects work fine for me.
Until you come up with a better bug report there is nothing I can do to help you.

JASS:
function main takes nothing returns nothing
    call SetCameraBounds(- 7680.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), - 7680.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM), 7168.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), 7168.0 - GetCameraMargin(CAMERA_MARGIN_TOP), - 7680.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), 7168.0 - GetCameraMargin(CAMERA_MARGIN_TOP), 7168.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), - 7680.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM))
    call SetDayNightModels("Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl", "Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdl")
    call NewSoundEnvironment("Default")
    call SetAmbientDaySound("SunkenRuinsDay")
    call SetAmbientNightSound("SunkenRuinsNight")
    call SetMapMusic("Music", true, 0)
    call InitSounds()
    call CreateRegions()   // <--------<<  rects are created here
    call CreateAllDestructables()
    call CreateAllUnits()
    call InitBlizzard()

call ExecuteFunc("jasshelper__initstructs5502")   // <------<< vJass inits

    call InitGlobals()  // <------<< GUI global variables
    call InitCustomTriggers()
    call RunInitializationTriggers()

endfunction

Now stop trolling.
 
Then try saving this map with your JH and see what happens >.>.


It tells me that the variables do not exist.


This map also had the broken main function.


Also extract luadir to your grimext folder in order to make it run.


And yes, that map runs perfectly with plain JH, but blows to pieces under yours ;\.

edit
sry if I'm being harsh ^)^, I was just going wth at all the weird syntax errors + I've been up all night : P.
 

Attachments

  • WMW Masters 1.2.0.2.w3x
    1.1 MB · Views: 65
  • luadir.zip
    30.2 KB · Views: 63
Level 6
Joined
Jun 16, 2007
Messages
235
It works fine for me.
Did you by any chance forget to update to the latest version from today?
2012-02-07b
 
Level 6
Joined
Jun 16, 2007
Messages
235
I guess //! import directive did not strike you as important in a map with 40 external files?

F****** Troll
 
Level 6
Joined
Jun 16, 2007
Messages
235
Bugfix 2012-02-07c
Fixed //! external directive bug caused by //! import directive fix

It is a good thing Nestharus gave me his buggy map to experiment on :ogre_hurrhurr:

This recent jasshelper instability just goes to show how many things I needed to change to make proper initialization order.
It took me 4 days of hard work for it, dusk till dawn.
 
Level 7
Joined
Oct 11, 2008
Messages
304
Nes, JassHelper ALWAYS has that 'bug' (read, thanks Blizzard) about the GUI variable.

You can search all the forum, here or thehelper, and you'll find lots of people asking about something like that.

Why my function based on Rect don't work?
Why my preplaced unit don't work?

It's all about 'initializer', in the older JH, it just compile and show no error, but still didn't work, also, if you want it to work, you need to do it at some 'normal onInit' (not module) and/or call it from the init function.
 
It's all about 'initializer', in the older JH, it just compile and show no error, but still didn't work, also, if you want it to work, you need to do it at some 'normal onInit' (not module) and/or call it from the init function.

They work for me? lol

oh yea, Cohador, improve your parsing of to and for. Variables might be named that. Whenever you add new keywords, be sure to do some excellent parsing on them, otherwise you will break resources that have those labels ^)^. For example, my Timer Tools resource does not work on this jasshelper because it shorthands timeout -> to.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
I've tried to save the attached map with the newest version and few older ones, but the vJass initializer is never called in the main function.
Maybe it's because it has "init" in his name, i called it init2, just because init didn't work neither in the first place.
And yes i've tried with the last "official" jasshelper by Vexorian and the script is compiled as intented.
 

Attachments

  • test.w3m
    12 KB · Views: 60
Level 6
Joined
Jun 16, 2007
Messages
235
Bugfix 2012-02-09
Map was not working because you did not have any structs in it :)

Border cases always cause problems.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Ok.

Btw i'm not sure it's a good idea to rename the generated text files, sure {input/output}_war3map.j seems neater than {input/output}war3map.j
It's stupid, but i had a hard time to figure that was these files, the first time i wanted to check the generated jass file.
I mean we all have the habit of the older names (at least the ones who knew them).
And what about third party tools using them (just a thought).
Now, i suppose it's fine you don't recreate the current file, since it's supposed to be the same as the output one.
 
Level 6
Joined
Jun 16, 2007
Messages
235
No tool uses these files directly.
(It is not possible because they change during compilation)
//! external directive works on whole map file.

I made the name change so I can have both old jasshelper and new one compile at same time and not step on each other.

current file was a temporary storage file but is not used any more because compilation was optimized to be done entirely in memory.
 
Level 6
Joined
Jun 16, 2007
Messages
235
Wine slows things down, I doubt you would want to install it on hives server.

NOTE: There are 2 command line versions of jasshelper:
1. one that processes map .w3x files from command line
2. one that processes only textual war3map.j script from command line.

The first one depends on windows.
The second one could (in theory) be made to work natively on linux.

If Ralle was thinking about script processing version maybe I could do something.
I have linux box at home but as always I am short with time.
Don't expect anything soon.

//==============================================//

New Version 2012-02-10

This version can hopefully be considered stable for the time being.
There will be no major changes for some time.

I am planning on some big redesigns so that jasshelper gives better error messages when something goes wrong.
Messages should tell you the trigger and line number inside the trigger when error happens,
not a global line number in a half-compiled .j file.

This will take a while, don't hold your breath.
 
Status
Not open for further replies.
Top