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. cohadar

    cohadar

    Joined:
    Jun 16, 2007
    Messages:
    234
    Resources:
    0
    Resources:
    0
    Maybe the case does not exist, maybe it does?
    The fact is I personally am not totally sure it would be safe to remove them.
    My programming instincts tell me to do it the standard way.
    Like I said, parentheses are pure semantic elements, they just order precedence, so there is really no real reason to remove them except saving 2 bytes in input script.

    I am doing some mayor refactoring, all this talk just seems irrelevant to me now.
    New error reporting style is coming and new function interfaces are coming, prepare yourself to be amazed.
     
  2. cohadar

    cohadar

    Joined:
    Jun 16, 2007
    Messages:
    234
    Resources:
    0
    Resources:
    0
    I am undecided about one jasshelper feature.
    Please Vote
     
  3. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,190
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Definitely to stay with "requires"?

    Care to share more on what you mean by new interfaces? Would this also address the ".name" issue which I mentioned earlier?
     
  4. moyackx

    moyackx

    Joined:
    Feb 15, 2006
    Messages:
    800
    Resources:
    7
    Maps:
    4
    Spells:
    2
    Tutorials:
    1
    Resources:
    7
    Requires is the most logical keyword, those synonyms seems to put more useless work to JH.
     
  5. Frotty

    Frotty

    Wurst Reviewer

    Joined:
    Jan 1, 2009
    Messages:
    1,476
    Resources:
    11
    Models:
    3
    Tools:
    1
    Maps:
    5
    Tutorials:
    1
    Wurst:
    1
    Resources:
    11
    More useless work?? These 3 keywords are 1 line with an orExpression ( requires|needs|uses)
     
  6. Troll-Brain

    Troll-Brain

    Joined:
    Apr 27, 2008
    Messages:
    2,372
    Resources:
    1
    JASS:
    1
    Resources:
    1
  7. cohadar

    cohadar

    Joined:
    Jun 16, 2007
    Messages:
    234
    Resources:
    0
    Resources:
    0
    @Bribe
    Function interfaces will not change on the outside.
    But new implementation will be faster, safer and will not generate parts that are not needed.

    But before I can do them I must finish new bug reporting mechanism.

    Currently bug reporting in jasshelper shows you the compiled text when it catches error in later stages. This is ugly and confusing.

    New mechanism will ALWAYS give you error report on your original (uncompiled) text.
     
  8. cohadar

    cohadar

    Joined:
    Jun 16, 2007
    Messages:
    234
    Resources:
    0
    Resources:
    0
  9. mckill2009

    mckill2009

    Joined:
    Mar 10, 2009
    Messages:
    4,696
    Resources:
    34
    Maps:
    5
    Spells:
    27
    JASS:
    2
    Resources:
    34
    I know this is off-topic but it would be great if someone has the skill to edit the object editor exporting/importing
    method, means if you import things, the previous data wont be erased or overwitten by the new one, just 'adds'
    the data, coz opening/saving/cnp is just pain...
     
  10. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,146
    Resources:
    8
    Spells:
    3
    Tutorials:
    4
    JASS:
    1
    Resources:
    8
    An idea that a lot of people have been wanting if you haven't yet implemented

    Top down ordering of methods inside of a struct to prevent trigger evaluation generation when implementing modules. If it's impossible to order a given method, then and only then generate a trigger for it (I'd prefer if it displayed an error myself though). This will make it so that we don't have to create 2-3 modules to implement to prevent triggers from being generated.

    Also, if a method is to be inlined, it should never be generating a trigger ^)^.



    Automatic fixing of returned local non arg handles ; O (yes, they do leak pointers).

    Code (vJASS):

    function ReturnSomething takes nothing returns unit
        local unit u = CreateUnit(Player(0), 'hfoo', 0, 0, 0)

        return u //leak!
    endfunction
     


    to

    Code (vJASS):

    globals
        unit returnUnt
    endglobals
    function ReturnSomething takes nothing returns unit
        local unit u = CreateUnit(Player(0), 'hfoo', 0, 0, 0)

        set returnUnit = u
        set u = null
        return returnUnit //no longer leaks ^)^
    endfunction
     


    Only 1 variable should be generated for any given handle (please don't spam 1 for every function).



    Eventually, at some point, it would be cool to be able to access object editor data from JASS. You could store it in a dictionary or something and then when you see something like Objects, you'll know that they want to read from the dictionary.

    for example
    Objects["units"]['hpea']["usei"]

    And if something is an array of items
    Objects["units]['hpea']["utra"][0]

    From there, should be able to use some sort of reflection to figure out the returned item for a given array (if the item may have been an upgrade, a unit, an item, or w/e). Also should include some nice polymorphism. For example, items, upgrades, and units share gold and lumber costs ; ).

    Objects["units"]['hpea']["ureq"][0].type("units")?


    This would ofc be a feature for a much later date. It would make some libs like GetUnitCollision deprecated. I'm sure a lot of people would appreciate this ; ).
     
  11. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,190
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    @Nestharus, you can already do object editor retrieval by reading from SLK files.

    http://www.wc3c.net/vexorian/jasshelpermanual.html#slk

    It's lazy to rely on a compiler to create global return values. By this much time coding in JASS we are all accustomed to removing leaks ourselves.
     
  12. Troll-Brain

    Troll-Brain

    Joined:
    Apr 27, 2008
    Messages:
    2,372
    Resources:
    1
    JASS:
    1
    Resources:
    1
    This one is already possible, add the tag [forcemethodevaluate] to jasshelper.conf.
    I also personnaly use [noshadowfixer]

    EDIT : And now that i'm thinking about it i would also use [noimplicitthis].

    Code (vJASS):
    struct S

        integer data

        method m takes integer data returns nothing
            set (this).data = data
            // "set data = data" wouldn't work so well, and even if does , the syntax is senseless
        endmethod

    endstruct
     
  13. cohadar

    cohadar

    Joined:
    Jun 16, 2007
    Messages:
    234
    Resources:
    0
    Resources:
    0
    Yes everybody has ideas about what I should do for them.
    But when I ask for a little help with writing tests noone is around.
     
  14. Troll-Brain

    Troll-Brain

    Joined:
    Apr 27, 2008
    Messages:
    2,372
    Resources:
    1
    JASS:
    1
    Resources:
    1
    Damned human beings.

    I will do some tests ... later
     
  15. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,943
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    All this reminds me of LaTeX and how unusuable it is to do anything functional...

    I would much rather see merging of Vexorian's script optimizer into JassHelper than new features that people use just because they think it is clever to use instead of actually because they are needed.

    Not possible. There are situations where some handles are never removed so the reference counter is purposly left to leak as part of an optimization (eg local players which can never be truely destroyed). Some maps might also implement recycling systems for objects like timers and groups which again are unaffected by reference leaks due to never getting destroyed.

    Or you could just mod StarCraft II where the game nativly supports such functionality. I would leave it at a macro command atmost which would look up the value at precompiler time.

    Since we are covering pointless features, how about the ability to set arrays neatly?
    set array = {N...a,b,c,d,e,etc}
    Where N is an initial offset.

    integer array arr
    // set index 0 to 1 ... etc ... index 4 to 5
    set arr = {1,2,3,4,5}
    // set index 5 to 1 ... etc ... index 9 to 5
    set arr = {5...1,2,3,4,5}
    // also needs multi line support
    Code (Text):

    set arr = {5...
                  1,
                  2,
                  3,
                  4,
                  5}
     
    The precopiler generates the following.
    set array = {N...a,b,c,etc}
    becomes
    Code (vJASS):

    set array[N] = a
    set array[N+1] = b
    set array[N+2] = c
    ...
     


    Obviously you apply a numeric constants optimizer to it so that an expression like
    set arr = {5...1,2,3} // N is a constant
    becomes
    Code (vJASS):

    set arr[5] = 1
    set arr[6] = 2
    set arr[7] = 3
     


    The reason to introduce such a feature is to greatly improve the usability of arrays when storing bulk data (such as table entries).

    Lets say we have a wave system for a towerdefense. Currently one has to apply a set line for each entry (wave) and compute the index manually. If you compute the index dynamicly then you incure a performance penalty for no reason (as the indexes you are setting are constant). With this feature it would allow you to set all waves with a single set statement and make changes such as deletion or insertion without having to recompute all the constant indexes. This becomes very user friendly for people to use such a system as they are modifying a table like structure rather than JASS arrays which a lot of people do not undertstand.

    Even though it would support dynamic offsets, the advantage purly becomes code neatness rather than ease of use.
     
  16. cohadar

    cohadar

    Joined:
    Jun 16, 2007
    Messages:
    234
    Resources:
    0
    Resources:
    0
    Finally someone with a good idea.
    Multi line support is really hard to add thou since jass is line oriented language.

    also syntax could be better, for example:
    Code (vJASS):

    set myArray[5..] = "five", "six", "seven", "eight"
     


    EDIT:
    lol I just realized THIS is what SLK files are about.
    http://www.wc3c.net/vexorian/jasshelpermanual.html#slk

    Vexorian left so many things badly documented that you can often find he already implemented something you need, but you just never heard about it.
     
    Last edited: Feb 17, 2012
  17. Troll-Brain

    Troll-Brain

    Joined:
    Apr 27, 2008
    Messages:
    2,372
    Resources:
    1
    JASS:
    1
    Resources:
    1
    Some native functions don't work or even make wc3 crash if they are used in the global definition.

    For example CreateRegion doesn't work, while GetLocalPlayer make wc3 crash.
    It could be easily fixed by setting the globals in the main function instead.
    But maybe it's just too much, it's just a suggestion.

    It would allow even more fancy stuff, such as using custom functions.
     
  18. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,190
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    It would be pretty annoying to find out which ones don't work and which ones don't, and add them to a list which gets added to the main function, so the compiler can change what the user could have changed already. It would also need an ExecuteFunc of its own, to avoid op limit risks.

    Now that library initializers are run with the same priority as modules, it's not adding a lot of work to the user to move the occasional Rect/CreateUnit/Item/Destructable/Region call to that dedicated function.
     
  19. Troll-Brain

    Troll-Brain

    Joined:
    Apr 27, 2008
    Messages:
    2,372
    Resources:
    1
    JASS:
    1
    Resources:
    1
    The thing is that you don't need to find them, just make the false assumption that they are not working correctly.
    I mean move all globals definition in the main function.
    About the op-limit, you would have to init several thousands of globals to reach it.
    Now instead of be included directly in the main function, it could be used in a custom dedicaced function, and then called through ExecuteFunc in the main function.
    The only cost will be few bytes more (the variables names will be used 2 times instead of just one, and with an additional "set ")

    It's clearly not the OMG-i-need-this-feature-so-much, in fact i don't care that much.
    I just find it as a neat feature, and is in my to-do list for my own jass pre-processor (just because i can)
     
  20. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,190
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Honestly I'd rather keep it the way it is, because things like CreateGroup, CreateTimer, Location, InitHashtable and some others work just fine.