1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The reforging of the races is complete. Come see the 14th Techtree Contest Results.
    Dismiss Notice
  4. It's time to choose your horse in the race - the 32nd Modeling Contest Poll is up!
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Jasshelper 2011-12-19

Discussion in 'Warcraft Editing Tools' started by cohadar, Dec 19, 2011.

  1. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,190
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    cJass doesn't compile my re-write of the Table library, which was a big WTF moment.
     
  2. moyackx

    moyackx

    Joined:
    Feb 15, 2006
    Messages:
    800
    Resources:
    7
    Maps:
    4
    Spells:
    2
    Tutorials:
    1
    Resources:
    7
    I just want to confirm if this jasshelper ensures compatibility with the features of version 0.2.A.B

    IF that's the case, then I'll update my JNGP with this JH version.
     
  3. SanKakU

    SanKakU

    Joined:
    May 11, 2008
    Messages:
    1,183
    Resources:
    1
    Maps:
    1
    Resources:
    1
    i don't know...there are so many systems out there, i sometimes get confused which is which. did your re-write look anything like this?

    Code (vJASS):
    library Table
    //***************************************************************
    //* Table object 3.0
    //* ------------
    //*
    //*   set t=Table.create() - instanceates a new table object
    //*   call t.destroy()     - destroys it
    //*   t[1234567]           - Get value for key 1234567
    //*                          (zero if not assigned previously)
    //*   set t[12341]=32      - Assigning it.
    //*   call t.flush(12341)  - Flushes the stored value, so it
    //*                          doesn't use any more memory
    //*   t.exists(32)         - Was key 32 assigned? Notice
    //*                          that flush() unassigns values.
    //*   call t.reset()       - Flushes the whole contents of the
    //*                          Table.
    //*
    //*   call t.destroy()     - Does reset() and also recycles the id.
    //*
    //*   If you use HandleTable instead of Table, it is the same
    //* but it uses handles as keys, the same with StringTable.
    //*
    //*  You can use Table on structs' onInit  if the struct is
    //* placed in a library that requires Table or outside a library.
    //*
    //*  You can also do 2D array syntax if you want to touch
    //* mission keys directly, however, since this is shared space
    //* you may want to prefix your mission keys accordingly:
    //*
    //*  set Table["thisstring"][ 7 ] = 2
    //*  set Table["thisstring"][ 5 ] = Table["thisstring"][7]
    //*
    //***************************************************************

    //=============================================================
        globals
            private constant integer MAX_INSTANCES=8100 //400000
            //Feel free to change max instances if necessary, it will only affect allocation
            //speed which shouldn't matter that much.

        //=========================================================
            private hashtable ht
        endglobals

        private struct GTable[MAX_INSTANCES]

            method reset takes nothing returns nothing
                call FlushChildHashtable(ht, integer(this) )
            endmethod

            private method onDestroy takes nothing returns nothing
                call this.reset()
            endmethod

            //=============================================================
            // initialize it all.
            //
            private static method onInit takes nothing returns nothing
                set ht = InitHashtable()
            endmethod

        endstruct

        //Hey: Don't instanciate other people's textmacros that you are not supposed to, thanks.
        //! textmacro Table__make takes name, type, key
        struct $name$ extends GTable

            method operator [] takes $type$ key returns integer
                return LoadInteger(ht, integer(this), $key$)
            endmethod

            method operator []= takes $type$ key, integer value returns nothing
                call SaveInteger(ht,  integer(this)  ,$key$, value)
            endmethod

            method flush takes $type$ key returns nothing
                call RemoveSavedInteger(ht, integer(this), $key$)
            endmethod

            method exists takes $type$ key returns boolean
                return HaveSavedInteger( ht,  integer(this)  ,$key$)
            endmethod

            static method flush2D takes string firstkey returns nothing
                call $name$(- StringHash(firstkey)).reset()
            endmethod

            static method operator [] takes string firstkey returns $name$
                return $name$(- StringHash(firstkey) )
            endmethod

        endstruct
        //! endtextmacro

        //! runtextmacro Table__make("Table","integer","key" )
        //! runtextmacro Table__make("StringTable","string", "StringHash(key)" )
        //! runtextmacro Table__make("HandleTable","handle","GetHandleId(key)" )

    endlibrary
     
     
  4. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    According to Cohadar and others, it is fully compatible. Cohadar said he didn't break any backwards compatibility, so there shouldn't be any problems on that end.
     
  5. watermelon_1234

    watermelon_1234

    Joined:
    Nov 18, 2007
    Messages:
    1,066
    Resources:
    10
    Spells:
    9
    JASS:
    1
    Resources:
    10
    Probably the only real compatibility broken is due to the new keywords but that shouldn't be too much of a problem as a simple replace can easily fix it.

    Anyway I have something like this:
    Code (vJASS):
            local integer lvl = GetUnitAbilityLevel(SpellEvent.CastingUnit, SPELL_ID)
            local unit u  
           
            call GroupEnumUnitsInArea(ENUM_GROUP, SpellEvent.TargetX, SpellEvent.TargetY, Area(lvl), null)
            for u in ENUM_GROUP
                if AffectedTargets(u, GetTriggerPlayer()) then
                    call buffType.apply(u, SpellEvent.CastingUnit, lvl, Duration(lvl))            
                endif
            endfor
    The problem is that it compiles to this:
    Code (vJASS):
            local integer lvl= GetUnitAbilityLevel(s__SpellEvent___spellEvent_CastingUnit[SpellEvent], ShadowStride___SPELL_ID)
            local unit u
            call GroupEnumUnitsInArea(ENUM_GROUP , s__SpellEvent___spellEvent_TargetX[SpellEvent] , s__SpellEvent___spellEvent_TargetY[SpellEvent] , ShadowStride___Area(lvl) , null)
                if ShadowStride___AffectedTargets(u , GetTriggerPlayer()) then
                    call s__ShadowStride_buffType_apply(u , s__SpellEvent___spellEvent_CastingUnit[SpellEvent] , lvl , ShadowStride___Duration(lvl))
                endif
            endloop // endfor
    It basically looks like the compiler ignored the first for statement.
    From my testing, it looks like functions that follow a function interface break the new loops (In my case, the code was in a function that had to follow the function interface for SpellEvent, takes nothing and returns nothing).

    Shorter example:
    Code (vJASS):
        private function SpellActions takes nothing returns nothing
            // This doesn't compile!  
            while true
            endwhile
        endfunction
       
        private function Init takes nothing returns nothing
            call RegisterSpellEffectResponse(SPELL_ID, SpellActions)        
        endfunction
     
  6. cohadar

    cohadar

    Joined:
    Jun 16, 2007
    Messages:
    234
    Resources:
    0
    Resources:
    0
    It works for me just fine. What version of jasshelper are you using?
    Do you use anything besides jasshelper?

    I also was not able to reproduce that function-interface + for error,
    post a demo map with error please.

    =============================
    I would like to ask people who talk about cJass to go somewhere else.
    jasshelper has nothing to do with cJass and any problems you have with cJass should be directed to the makers of cJass.
     
  7. SanKakU

    SanKakU

    Joined:
    May 11, 2008
    Messages:
    1,183
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Cohadar, if you think mentioning cJass is unrelated to jasshelper, let me tell you something. if you can convince me that the extra requirements are useful, i'll stop talking about cJass and start using all the newfangled jasshelper 'improvements'.
     
  8. cohadar

    cohadar

    Joined:
    Jun 16, 2007
    Messages:
    234
    Resources:
    0
    Resources:
    0
    I don't even know what you are talking about.
    What extra requirements?
     
  9. watermelon_1234

    watermelon_1234

    Joined:
    Nov 18, 2007
    Messages:
    1,066
    Resources:
    10
    Spells:
    9
    JASS:
    1
    Resources:
    10
    Test map
    Just to be clear, I'm only talking about the new loops having a problem with function interfaces that get registered. If
    call RegisterSpellEffectResponse(0, SpellActions) 
    is commented out, the map compiles successfully.

    I do have the latest JassHelper. (2012-01-07)
    I was also able to reproduce the error by trying to compile a test script with Jasshelper alone.
     
    Last edited: Jan 14, 2012
  10. cohadar

    cohadar

    Joined:
    Jun 16, 2007
    Messages:
    234
    Resources:
    0
    Resources:
    0
    Ah, yes, the function interfaces are stomping over the new loops.
    I am working on it...
     
  11. cohadar

    cohadar

    Joined:
    Jun 16, 2007
    Messages:
    234
    Resources:
    0
    Resources:
    0
    ... and fixed! 2012-01-14

    Thanks for great bug report watermelon_1234.
     
  12. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,190
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Could you please make it so that "FunctionName.name" only converts the string, instead of also writing up all the duplicated "prototype" functions?

    FunctionName.name is a good trick to using ExecuteFunc, because ExecuteFunc avoids handles, allows TriggerSleepAction, and ".name" allows the function to be private or within a struct. Never mind the speed, because I really could care less.

    What I want it to do, and what JassHelper manual says it does, is just to compile the string, and not adding the extra proxy function + trigger + condition as well. Because the way JassHelper has it set up now, is that it gains absolutely no advantage to use ".name" instead of ".execute".
     
  13. cohadar

    cohadar

    Joined:
    Jun 16, 2007
    Messages:
    234
    Resources:
    0
    Resources:
    0
    When ever jasshelper detects function.something it adds function to the list of prototyped ones, so everything is generated.

    Sure I could add one more boolean to check if you only used .name, so yes what you ask could be done.

    But I have no time atm, and your request is not critical.

    I will do it in the next big release when I fix initialization orders,
    and that will happen in about 15 days. (when I expect I will have free time)
     
  14. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,190
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    That makes sense actually. I am in no rush either, and I don't care about it being a priority, it just seemed like a reason for me to start using this JassHelper (which hasn't yet added a feature that made me "want it", because I enjoy writing out loops).
     
  15. SanKakU

    SanKakU

    Joined:
    May 11, 2008
    Messages:
    1,183
    Resources:
    1
    Maps:
    1
    Resources:
    1
    and as for me i could use cjass loops...and stick to scopes and libraries...lol

    who needs modules? not me, i think...
     
  16. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,190
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    cJass has many errors still, which were not addressed by their team. And the team left the project unfinished.
     
  17. Troll-Brain

    Troll-Brain

    Joined:
    Apr 27, 2008
    Messages:
    2,372
    Resources:
    1
    JASS:
    1
    Resources:
    1
    I'm not sure that spamming strings is a good idea in jass though, i would still use .execute, or even ForForce if i care about generated handles and script size.
     
  18. Black_meoonG

    Black_meoonG

    Joined:
    Sep 1, 2010
    Messages:
    51
    Resources:
    0
    Resources:
    0
    it seems almost optimal :)
    why don't you put this tool at this section ??
    so i can rate it.. ;)
     
  19. cohadar

    cohadar

    Joined:
    Jun 16, 2007
    Messages:
    234
    Resources:
    0
    Resources:
    0
    This is a development version.
    Meaning more updates are coming and more testing will be needed before it can be declared stable to use by community.
     
  20. cohadar

    cohadar

    Joined:
    Jun 16, 2007
    Messages:
    234
    Resources:
    0
    Resources:
    0
    New Version: 2012-02-06

    //=====================================
    // 2012-02-06
    //=====================================
    * Fixed library, scope, struct and module initialization orders.
    * Fixed initialization order for structs not inside scope or library.
    * InitTrig functions are no longer valid inside scopes and libraries.

    New initialization order goes like this:
    • Library Blocks
    • Scope Blocks
    • Anonymous jass
    • GUI

    Inside Library or Scope blocks order is like this:
    • struct1-module1 init
    • struct1-module2 init
    • struct1 init
    • struct2-module1 init
    • struct2-module2 init
    • struct2 init
    • block init

    Functions with InitTrig prefix are NO LONGER VALID inside libraries and scopes.
    This is now an error: (implicit InitTrig calls are reserved for GUI triggers)
    Code (vJASS):

    scope ScopeName

    //========ERROR==============================================================
    function InitTrig_ScopeName takes nothing returns nothing
        set gg_trg_ScopeName = CreateTrigger(  )
        call TriggerRegisterTimerEventSingle( gg_trg_ScopeName, 5 )
        call TriggerAddCondition( gg_trg_ScopeName, Condition( function Trig_ScopeName_Conditions ) )
        call TriggerAddAction( gg_trg_ScopeName, function Trig_ScopeName_Actions )
    endfunction
    endscope
     


    This is correct:
    Code (vJASS):

    scope ScopeName initializer Init

    //===========================================================================
    function Init takes nothing returns nothing
        set gg_trg_ScopeName = CreateTrigger(  )
        call TriggerRegisterTimerEventSingle( gg_trg_ScopeName, 5 )
        call TriggerAddCondition( gg_trg_ScopeName, Condition( function Trig_ScopeName_Conditions ) )
        call TriggerAddAction( gg_trg_ScopeName, function Trig_ScopeName_Actions )
    endfunction
    endscope