• 🏆 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!

Jasshelper 2011-12-19

Status
Not open for further replies.

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,180
Mac and Windows use a different new line character? I thought both used \n as the new line but Windows expects a carrage return character afterwards (2 characters instead of 1).

Adding new keywords or major behaviour revisions is not a good idea once a language is established. If you want them you need to develop in parallel as a new language (like vJASS2.0) to avoid backwards compatibility problems (such as someone naming a variable to). This could be done by a hidden comment (like the scrole position JNGP makes) or a macro command which tells which precompiler is to run on a piece of script. Ofcourse you encourage people to switch over to vJASS2.0 but by doing this you do not break existing code.

This is the whole problem with standards. Once they are established it is very difficult to make changes, even if they are constructive. OpenGL is a good example of this as it is foreced to remain backwards compatible due to popular demand even though it comes at a heavy performance penalty. Only recently has OpenGL managed to overcome this with the introduction of versions 3 and 4 which were parallel extensions to the standard. Direct3D also suffered this under its 9 version, which is why 10's standard was not backwards compatible (needed new OS and Hardware).
 
Level 5
Joined
Dec 1, 2008
Messages
120
Getting random runtime errors (Runtime error 216 at 00404146) with this. Sometimes it just freezes whole NewGen, and I have to kill the process.

With Vexorian's everything works just fine.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Getting random runtime errors (Runtime error 216 at 00404146) with this. Sometimes it just freezes whole NewGen, and I have to kill the process.

With Vexorian's everything works just fine.

i get them too.. I also believe that this jasshelper leaks... editor memory usage in task manager goes up every time I save. I had it using like 500 megs of ram at one point.
 
Level 6
Joined
Jun 16, 2007
Messages
235
What runtime errors? when? why? (it cannot be random)
Any example of code that does it?
Can someone make a decent bug report?

And jasshelper cannot leak memory because it is not a resident process,
it terminates after it saves the map.
What is leaking is probably TESH, and that is not my problem.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
What runtime errors? when? why? (it cannot be random)

For me, it's happened only when I've tried to find text with CTRL+F, and only two times out of many (rather random). It only started doing this with your stuff.

As for the memory leaks, I suppose TESH might leak since my laptop used to always freeze with WE ; ). Well, actually I use horus or w/e, but anyways.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Every time I type something, this window pops up

attachment.php



Care to elaborate on what it is? ^)^
 

Attachments

  • error.jpg
    error.jpg
    362.9 KB · Views: 250
Level 31
Joined
Jul 10, 2007
Messages
6,306
This doesn't work..

JASS:
    globals
        debug private boolean array al
        debug private boolean array alm
        debug private boolean en = true
    endglobals

And this is included with or without debug mode still
JASS:
static if DEBUG_MODE
    globals
        private boolean array al
        private boolean array alm
        private boolean en = true
    endglobals
endif

This doesn't work as well
JASS:
debug private function Hi takes nothing returns nothing
debug endfunction

For now, I am doing this
JASS:
    static if DEBUG_MODE then
        private struct DEB extends array
            static boolean array al
            static boolean array DEB.alm
            static boolean DEB.en = true
        endstruct
    endif

Quite the annoying workaround ; p


So what I think needs to be done is
debug global

globals in order of appearance with precedence with static if magic


Then there will be no more weird behavior for static ifs ^^


edit
Modules apparently don't work either...

Attached map does not save when you enable the CTM Not Working trig


I tested it and it happens when more than 1 of that module is implemented.

Also, when enabling both trigs, it magically works again...

edit
Another error.. apparently I can only implement my CTM module in 45 different structs before jasshelper crashes... at #46, it tells me, unexpected this.. at #47, it just totally freezes.

looks like these benchmarks I want to do will have to wait until you fix this : (

edit
I Have Discovered The Culprit!
It's structs w/ onInit... and the bug is freaking weird...

Here is a prime example.. this works
JASS:
//! textmacro TEST takes I, T
struct Tester$I$ extends array
    private static constant real TIMEOUT = .$T$
    private static integer did = TO_DO
    
    implement CTMExpire
    implement CTMEnd
    private static method run takes nothing returns nothing
        local integer i = did
        set did = did - RATE
        if (0 > did) then
            set did = 0
        endif
        loop
            exitwhen did == i
            call create(TIMEOUT)
            set i = i - 1
        endloop
        if (0 == did) then
            call PauseTimer(GetExpiredTimer())
            call DestroyTimer(GetExpiredTimer())
        endif
    endmethod
    private static method onInit takes nothing returns nothing
        call TimerStart(CreateTimer(), RUN_TIME, true, function thistype.run)
    endmethod
endstruct

//! endtextmacro

//! runtextmacro TEST("0", "10")
//! runtextmacro TEST("1", "11")
//! runtextmacro TEST("2", "12")
//! runtextmacro TEST("3", "13")
//! runtextmacro TEST("4", "14")
//! runtextmacro TEST("5", "15")
//! runtextmacro TEST("6", "16")
//! runtextmacro TEST("7", "17")
//! runtextmacro TEST("8", "18")
//! runtextmacro TEST("9", "19")

//! runtextmacro TEST("10", "10")
//! runtextmacro TEST("11", "11")
//! runtextmacro TEST("12", "12")
//! runtextmacro TEST("13", "13")
//! runtextmacro TEST("14", "14")
//! runtextmacro TEST("15", "15")
//! runtextmacro TEST("16", "16")
//! runtextmacro TEST("17", "17")
//! runtextmacro TEST("18", "18")
//! runtextmacro TEST("19", "19")

//! runtextmacro TEST("20", "10")
//! runtextmacro TEST("21", "11")
//! runtextmacro TEST("22", "12")
//! runtextmacro TEST("23", "13")
//! runtextmacro TEST("24", "14")
//! runtextmacro TEST("25", "15")
//! runtextmacro TEST("26", "16")
//! runtextmacro TEST("27", "17")
//! runtextmacro TEST("28", "18")
//! runtextmacro TEST("29", "19")

//! runtextmacro TEST("30", "10")
//! runtextmacro TEST("31", "11")
//! runtextmacro TEST("32", "12")
//! runtextmacro TEST("33", "13")
//! runtextmacro TEST("34", "14")

But this does not.. (the only difference is the carriage return yes...)
JASS:
//! textmacro TEST takes I, T
struct Tester$I$ extends array
    private static constant real TIMEOUT = .$T$
    private static integer did = TO_DO
    
    implement CTMExpire

    implement CTMEnd
    private static method run takes nothing returns nothing
        local integer i = did
        set did = did - RATE
        if (0 > did) then
            set did = 0
        endif
        loop
            exitwhen did == i
            call create(TIMEOUT)
            set i = i - 1
        endloop
        if (0 == did) then
            call PauseTimer(GetExpiredTimer())
            call DestroyTimer(GetExpiredTimer())
        endif
    endmethod
    private static method onInit takes nothing returns nothing
        call TimerStart(CreateTimer(), RUN_TIME, true, function thistype.run)
    endmethod
endstruct

//! endtextmacro

//! runtextmacro TEST("0", "10")
//! runtextmacro TEST("1", "11")
//! runtextmacro TEST("2", "12")
//! runtextmacro TEST("3", "13")
//! runtextmacro TEST("4", "14")
//! runtextmacro TEST("5", "15")
//! runtextmacro TEST("6", "16")
//! runtextmacro TEST("7", "17")
//! runtextmacro TEST("8", "18")
//! runtextmacro TEST("9", "19")

//! runtextmacro TEST("10", "10")
//! runtextmacro TEST("11", "11")
//! runtextmacro TEST("12", "12")
//! runtextmacro TEST("13", "13")
//! runtextmacro TEST("14", "14")
//! runtextmacro TEST("15", "15")
//! runtextmacro TEST("16", "16")
//! runtextmacro TEST("17", "17")
//! runtextmacro TEST("18", "18")
//! runtextmacro TEST("19", "19")

//! runtextmacro TEST("20", "10")
//! runtextmacro TEST("21", "11")
//! runtextmacro TEST("22", "12")
//! runtextmacro TEST("23", "13")
//! runtextmacro TEST("24", "14")
//! runtextmacro TEST("25", "15")
//! runtextmacro TEST("26", "16")
//! runtextmacro TEST("27", "17")
//! runtextmacro TEST("28", "18")
//! runtextmacro TEST("29", "19")

//! runtextmacro TEST("30", "10")
//! runtextmacro TEST("31", "11")
//! runtextmacro TEST("32", "12")
//! runtextmacro TEST("33", "13")
//! runtextmacro TEST("34", "14")

Also, it magically works if I have a crap load of functions in the map
JASS:
//! textmacro TEST2 takes I
    function A$I$m takes nothing returns nothing
    endfunction
    function B$I$$I$ takes nothing returns nothing
    endfunction
    function C$I$$I$ takes nothing returns nothing
    endfunction
    function D$I$$I$ takes nothing returns nothing
    endfunction
    function E$I$$I$ takes nothing returns nothing
    endfunction
    function F$I$$I$ takes nothing returns nothing
    endfunction
    function G$I$$I$ takes nothing returns nothing
    endfunction
    
    function A$I$0$I$ takes nothing returns nothing
    endfunction
    function A$I$1$I$ takes nothing returns nothing
    endfunction
    function A$I$2$I$ takes nothing returns nothing
    endfunction
    function A$I$3$I$ takes nothing returns nothing
    endfunction
    function A$I$4$I$ takes nothing returns nothing
    endfunction
    function A$I$5$I$ takes nothing returns nothing
    endfunction
    function A$I$6$I$ takes nothing returns nothing
    endfunction
    function A$I$7$I$ takes nothing returns nothing
    endfunction
    function A$I$8$I$ takes nothing returns nothing
    endfunction
    function A$I$9$I$ takes nothing returns nothing
    endfunction
    
    function A$I$10$I$ takes nothing returns nothing
    endfunction
    function A$I$11$I$ takes nothing returns nothing
    endfunction
    function A$I$12$I$ takes nothing returns nothing
    endfunction
    function A$I$13$I$ takes nothing returns nothing
    endfunction
    function A$I$14$I$ takes nothing returns nothing
    endfunction
    function A$I$15$I$ takes nothing returns nothing
    endfunction
    function A$I$16$I$ takes nothing returns nothing
    endfunction
    function A$I$17$I$ takes nothing returns nothing
    endfunction
    function A$I$18$I$ takes nothing returns nothing
    endfunction
    function A$I$19$I$ takes nothing returns nothing
    endfunction
    
    function A$I$20$I$ takes nothing returns nothing
    endfunction
    function A$I$21$I$ takes nothing returns nothing
    endfunction
    function A$I$22$I$ takes nothing returns nothing
    endfunction
    function A$I$23$I$ takes nothing returns nothing
    endfunction
    function A$I$24$I$ takes nothing returns nothing
    endfunction
    function A$I$25$I$ takes nothing returns nothing
    endfunction
    function A$I$26$I$ takes nothing returns nothing
    endfunction
    function A$I$27$I$ takes nothing returns nothing
    endfunction
    function A$I$28$I$ takes nothing returns nothing
    endfunction
    function A$I$29$I$ takes nothing returns nothing
    endfunction
//! endtextmacro

//! runtextmacro TEST2("0")
//! runtextmacro TEST2("1")
//! runtextmacro TEST2("2")
//! runtextmacro TEST2("3")
//! runtextmacro TEST2("4")
//! runtextmacro TEST2("5")
//! runtextmacro TEST2("6")
//! runtextmacro TEST2("7")
//! runtextmacro TEST2("8")
//! runtextmacro TEST2("9")

//! runtextmacro TEST2("10")
//! runtextmacro TEST2("11")
//! runtextmacro TEST2("12")
//! runtextmacro TEST2("13")
//! runtextmacro TEST2("14")
//! runtextmacro TEST2("15")
//! runtextmacro TEST2("16")
//! runtextmacro TEST2("17")
//! runtextmacro TEST2("18")
//! runtextmacro TEST2("19")

//! runtextmacro TEST2("20")
//! runtextmacro TEST2("21")
//! runtextmacro TEST2("22")
//! runtextmacro TEST2("23")
//! runtextmacro TEST2("24")
//! runtextmacro TEST2("25")
//! runtextmacro TEST2("26")
//! runtextmacro TEST2("27")
//! runtextmacro TEST2("28")
//! runtextmacro TEST2("29")

//! runtextmacro TEST2("30")
//! runtextmacro TEST2("31")
//! runtextmacro TEST2("32")
//! runtextmacro TEST2("33")
//! runtextmacro TEST2("34")
//! runtextmacro TEST2("35")
//! runtextmacro TEST2("36")
//! runtextmacro TEST2("37")
//! runtextmacro TEST2("38")
//! runtextmacro TEST2("39")

//! runtextmacro TEST2("40")
//! runtextmacro TEST2("41")
//! runtextmacro TEST2("42")
//! runtextmacro TEST2("43")
//! runtextmacro TEST2("44")
//! runtextmacro TEST2("45")
//! runtextmacro TEST2("46")
//! runtextmacro TEST2("47")
//! runtextmacro TEST2("48")
//! runtextmacro TEST2("49")

//! runtextmacro TEST2("50")
//! runtextmacro TEST2("51")
//! runtextmacro TEST2("52")
//! runtextmacro TEST2("53")
//! runtextmacro TEST2("54")
//! runtextmacro TEST2("55")
//! runtextmacro TEST2("56")
//! runtextmacro TEST2("57")
//! runtextmacro TEST2("58")
//! runtextmacro TEST2("59")

//! runtextmacro TEST2("60")
//! runtextmacro TEST2("61")
//! runtextmacro TEST2("62")
//! runtextmacro TEST2("63")
//! runtextmacro TEST2("64")
//! runtextmacro TEST2("65")
//! runtextmacro TEST2("66")
//! runtextmacro TEST2("67")
//! runtextmacro TEST2("68")
//! runtextmacro TEST2("69")

//! runtextmacro TEST2("70")
//! runtextmacro TEST2("71")
//! runtextmacro TEST2("72")
//! runtextmacro TEST2("73")
//! runtextmacro TEST2("74")
//! runtextmacro TEST2("75")
//! runtextmacro TEST2("76")
//! runtextmacro TEST2("77")
//! runtextmacro TEST2("78")
//! runtextmacro TEST2("79")
 

Attachments

  • Timer Tools.w3m
    20.2 KB · Views: 55
Last edited:
Level 6
Joined
Jun 16, 2007
Messages
235
Please when you report things make a distinction between old and new jasshelper.

The static if with globals thing is a problem of old jasshelper,
so what you are asking there is adding a new feature.

The rest is a bug report on new jasshelper.

You can expect the fix on Saturday, I have no time during work days.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
It would also be nice to eventually make it so that a function that takes something like
JASS:
struct Boo extends array
endstruct

function Ho takes Boo boo returns nothing
endfunction

Will fail on this
call Ho(1)

And succeed on this
call Ho(Boo(1))

And vice versa
JASS:
struct Boo extends array
endstruct

function Ho takes integer boo returns nothing
endfunction

call Ho(Boo(1)) //fail
call Ho(1) //succeed
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,180
Or you could re-engineer JASShelper for the GNU compilers.

The main program would have to be done in C/C++.
Parsing could be done using YACC (Yet Another Compiler Compiler).
Some routines could be exported to other cross platform languages like Java, Python or Pearl.

As long as platform dependencies in the C part are kept low by using GNU specified libraries it should compile and run on the three major platforms. The native based implementation should also give great speedups.
Of course for the macro scripts you would probably want some other interpreted language which would act as a bottleneck performance wise.

Libraries like the one used to interact with MPQs are already open source and provided in C/C++ so should be easy to compile cross platform.

The largest problem would be the amount of work required to port existing functionality to a new implementation which could instead be used to add new functionality to the existing implementation. The lack of man-power available probably renders this idea implausible.
 
Level 15
Joined
Feb 15, 2006
Messages
851
I'd rather get a legit Windows. WINE has issues even running WC3 videos from what I have read, and since Crossover by CodeWeavers seems to be just a GUI for WINE, I don't see it faring much better (and have seen pretty bad feedback for StarCraft 2 on both virtualizations).
Actually Crossover has better implementation of graphics and performance, and it creates a "windows installer" per game, which is very convenient and safe for playing.

I don't know, even Vexorian who claimed to be a linux freak wasn't motivated to do something for this platform which made me sad, for taht reason I have a windows partition just to play and mod the game without problems. Let's accept the fact that the games' market is windows and mac and we should be working in those platforms too.

If it serves as words of support, jasscraft runs nicely in vanilla wine :)
 
Level 6
Joined
Jun 16, 2007
Messages
235
Ok, noted, will be fixed.
But not serious enough for a new version.
(will have to wait some upgrade)
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,456
@Cohadar,

What do you think about readonly "global" variables? Currently it only works in structs, but if readonly could allow scope-wide variables to set it and not limit it to just structs, we could see some pretty nice syntax.

For example, if you want a "constant" reference variable which can't be set from an init block, you have to use ugly "get" syntax or ugly "struct" syntax if you want to prevent the variable from being able to be set by the user from outside the scope.
 
Level 6
Joined
Jun 16, 2007
Messages
235
Never thought of it, I use get syntax subconsciously (due to java background)
It is a nice idea, I am just out of time atm, so this goes under "maybe one day" category.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
edit
Bribe pointed out that Vex's jasshelper bugs up with this stuff too. Libraries like AIDS and UnitIndexer rely on inlining working properly, otherwise the lookups turn into trigger evaluations /cry.
end edit

Inlining bug

JASS:
globals
    integer hohoho = 0
endglobals

function Ho takes nothing returns nothing
    set hohoho = 5
endfunction

struct Hi extends array
    static method sets takes nothing returns nothing
        call setH()
    endmethod
    
    static method setH takes nothing returns nothing
        call Ho()
    endmethod
endstruct

Turns into
JASS:
function Ho takes nothing returns nothing
    set hohoho=5
endfunction

    function s__Hi_sets takes nothing returns nothing
        call TriggerEvaluate(st__Hi_setH) // INLINED!!
    endfunction
    
    function s__Hi_setH takes nothing returns nothing
        set hohoho=5 // INLINED!!
    endfunction

Please fix asap ;o

edit
Another example of the bug
JASS:
struct Hi extends array
    static method sets takes nothing returns nothing
        local integer i = thistype(5).h
    endmethod
    
    method operator h takes nothing returns integer
        return GetUnitUserData(null)
    endmethod
endstruct

Turns into
JASS:
    function s__Hi_sets takes nothing returns nothing
        local integer i= sc__Hi__get_h((5)) //function that evaluates a trigger
    endfunction
    
    function s__Hi__get_h takes integer this returns integer
        return GetUnitUserData(null)
    endfunction
 
Last edited:
Level 31
Joined
Jul 10, 2007
Messages
6,306
edit
nvm, Tukki pointed out my error ^)^
end edit

[] operators a bit buggy

This does no syntax error
JASS:
            if (incoming) then
                set node = this.incoming[damageType][damageSource].add(priority)
            else
                set node = this.outgoing[damageType][damageSource].add(priority)
            endif

where incoming/outgoing are structs that have [] operators

This does do a syntax error
JASS:
            if (incoming) then
                set node = incoming[damageType][damageSource].add(priority)
            else
                set node = outgoing[damageType][damageSource].add(priority)
            endif

Tells me incoming/outgoing are not arrays.
 
Last edited:
Level 6
Joined
Feb 10, 2008
Messages
300
JASS:
if (/*incoming*/) then
    set node = /*incoming*/[damageType][damageSource].add(priority)
else
    set node = outgoing[damageType][damageSource].add(priority)
endif

Possible that you've done the same with outgoing.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
edit
Bribe pointed out that Vex's jasshelper bugs up with this stuff too. Libraries like AIDS and UnitIndexer rely on inlining working properly, otherwise the lookups turn into trigger evaluations /cry.
end edit

Inlining bug

JASS:
globals
    integer hohoho = 0
endglobals

function Ho takes nothing returns nothing
    set hohoho = 5
endfunction

struct Hi extends array
    static method sets takes nothing returns nothing
        call setH()
    endmethod
    
    static method setH takes nothing returns nothing
        call Ho()
    endmethod
endstruct

Turns into
JASS:
function Ho takes nothing returns nothing
    set hohoho=5
endfunction

    function s__Hi_sets takes nothing returns nothing
        call TriggerEvaluate(st__Hi_setH) // INLINED!!
    endfunction
    
    function s__Hi_setH takes nothing returns nothing
        set hohoho=5 // INLINED!!
    endfunction

Please fix asap ;o

edit
Another example of the bug
JASS:
struct Hi extends array
    static method sets takes nothing returns nothing
        local integer i = thistype(5).h
    endmethod
    
    method operator h takes nothing returns integer
        return GetUnitUserData(null)
    endmethod
endstruct

Turns into
JASS:
    function s__Hi_sets takes nothing returns nothing
        local integer i= sc__Hi__get_h((5)) //function that evaluates a trigger
    endfunction
    
    function s__Hi__get_h takes integer this returns integer
        return GetUnitUserData(null)
    endfunction

That means you don't use the tag [forcemethodevaluate] in jasshelper.conf, else you would have a message on save.
I highly recommend you to use it, to avoid any unwanted auto TriggerEvaluate.

I suppose it worked in older jasshelper versions, because the optimizer wasn't used in the same process order, but really that makes sense to run in at the end.
So for your feature it requires to change again the order, that's unlikey Cohadar will do that.

Plus, what's the point of that, any real code to show ?
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
AIDS, Unit Indexer, Timer Tools, Constant Timer Loop 32, and any other module that calls user methods and has methods to be called in it.

That's why placing module correctly does matter.
For the average user, it would be better to use the tag [forcemethodevaluate]
I mean have you any real example with this recursive call ?

Plz highlight the code, since i suppose you know where to find it.
If it's not for me, do it for Cohadar.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Ahem, in constant timer loop 32, the code in the module may be calling code in the struct, and that code in the struct may be calling the code back in the module.


user timer code -> call destroy() (in struct)
struct code call stop (in module)

the destroyer has to be above the module so that the user's timer code can call it.
 
Level 12
Joined
Jul 11, 2010
Messages
422
I have a suggestion about the hooks. I think they should be more flexible.

There should be 2 more kinds of hooks, in my opinion :
- One that only calls the function instead of doing all this TriggerEvaluate thing. We definitely should have the choice, even if this solution causes problems in several situations, it would be usefull for the simpliest hooks that only use native functions and don't run much code. You may also give the option to use a TriggerExecute in the same way.
- One that totally replace the hooked function. Of course, the hook must not act inside the hooking function in that case. It would allow to call the function after the hooked one and get it's return value, for instance. It would also enable to make multiple calls (let's say if 2 objects are linked and that a function applying to one must apply to the other) or emulate the function with another.

An example of what could be done with those :

JASS:
function CreateItemHook takes integer itemid, real x, real y returns item
    local item it = CreateItem(itemid, x, y)
    call SetItemInvulnerable(it, true)
    return it // I know it leaks but that's example.
endfunction

// call and replace are the hook options.
// The 2 last words are the usual arguments.
hook call replace CreateItem CreateItemHook

...

   local item it = CreateItem('I000', 0, 0)

And the output would be something like :
JASS:
globals
trigger array st___prototype2
item f__result_item
integer f__arg_integer1
real f__arg_real1
real f__arg_real2

endglobals

// In current jasshelper, those functions are always created even if the "execute" version is never used.
// You may adapt the creation of them to the hook option ("call", "evaluate" or "execute").
function sc___prototype2_execute takes integer i,integer a1,real a2,real a3 returns nothing
    set f__arg_integer1=a1
    set f__arg_real1=a2
    set f__arg_real2=a3

    call TriggerExecute(st___prototype2[i])
endfunction
function sc___prototype2_evaluate takes integer i,integer a1,real a2,real a3 returns item
    set f__arg_integer1=a1
    set f__arg_real1=a2
    set f__arg_real2=a3

    call TriggerEvaluate(st___prototype2[i])
 return f__result_item
endfunction

// Hook function moved to the header. In the worse case, it just pops an "undeclared function error".
function CreateItemHook takes integer itemid,real x,real y returns item
    //hook: CreateItemHook call replace
    local item it= CreateItem(itemid, x, y) // CreateItem not hooked here.
    call SetItemInvulnerable(it, true)
    return it
endfunction

...

    call CreateItemHook('I000', 0, 0)

...

// jasshelper__initstructs functions ...

And the same example with an "evaluate" option :
JASS:
function CreateItemHook takes integer itemid, real x, real y returns item
    local item it = CreateItem(itemid, x, y)
    call SetItemInvulnerable(it, true)
    return it
endfunction

// Same as "hook replace CreateItem CreateItemHook"
hook evaluate replace CreateItem CreateItemHook

...

   local item it = CreateItem('I000', 0, 0)

And the output would be something like :
JASS:
globals
trigger array st___prototype2
item f__result_item
integer f__arg_integer1
real f__arg_real1
real f__arg_real2

endglobals

function sc___prototype2_execute takes integer i,integer a1,real a2,real a3 returns nothing
    set f__arg_integer1=a1
    set f__arg_real1=a2
    set f__arg_real2=a3

    call TriggerExecute(st___prototype2[i])
endfunction
function sc___prototype2_evaluate takes integer i,integer a1,real a2,real a3 returns item
    set f__arg_integer1=a1
    set f__arg_real1=a2
    set f__arg_real2=a3

    call TriggerEvaluate(st___prototype2[i])
 return f__result_item
endfunction

function h__CreateItem takes integer a0, real a1, real a2 returns item
    //hook: CreateItemHook
return sc___prototype2_evaluate(1,a0,a1,a2) // As a side note : this doesn't leak anymore.
endfunction

...

// Function not moved to top.
function CreateItemHook takes integer itemid,real x,real y returns item
    local item it= CreateItem(itemid, x, y) // CreateItem not hooked here.
    call SetItemInvulnerable(it, true)
    return it
endfunction

//processed hook: hook evaluate replace CreateItem CreateItemHook

...

    call h__CreateItem('I000', 0, 0)

...

// jasshelper__initstructs functions called at map initialization :
function sa___prototype2_CreateItemHook takes nothing returns boolean
 local integer itemid=f__arg_integer1
 local real x=f__arg_real1
 local real y=f__arg_real2

    local item it= CreateItem(itemid, x, y) // CreateItem not hooked here either.
    call SetItemInvulnerable(it, true)
    set f__result_item= it
    return true
endfunction

function jasshelper__initstructs1712796703 takes nothing returns nothing
    set st___prototype2[1]=CreateTrigger()
    call TriggerAddAction(st___prototype2[1],function sa___prototype2_CreateItemHook)
    call TriggerAddCondition(st___prototype2[1],Condition(function sa___prototype2_CreateItemHook))

endfunction


I hope it's clear and not too hard to make.

Thanks and congrats to update this tool. That's really an usefull work :goblin_good_job:.
 
Is it possible to change the color scheme on the editor? or do I have to live with it? ^_^

Do you mean the JASS text? That is a TESH thing, you can just click "Options" in your trigger editor to change it. (or whatever the button is) It should have some color scheme options iirc.

@Tirlititi: I also hope that update occurs, hooking would be pretty powerful then--and a lot more useful.
 
Status
Not open for further replies.
Top