Tutorial How To Convert To 1.24

Sevion

The DIY Ninja
Reaction score
413
How To Convert To 1.24b

How To Convert To 1.24b
By: Sevion​

This tutorial will teach you how to convert all of your resources to 1.24b, the newest (at the time of this tutorial) patch.

As most people know, this patch sucks. It broke almost all of the existing systems and maps, including DotA.

Update

Update any systems that have been updated by their creators to work with 1.24b.

Chances are, the system creators fixed the bug better than you did.

Return Bug

Find any thing that has two returns right after each other. An example:

JASS:
return 0.
return 1.


This is the famous "return bug" that converts a handle to an integer, effectively getting its ID. (And many other variations like I2U, U2I, I2T, T2I etc)

Note, as of 1.24b there is only one way to fix the above typecasting. And it's only for H2I and S2I. GetHandleId and StringHash respectively.

The DoNothing trick no longer working. Typecasting integers (handle id's) back to handles no longer works. You'll have to fix the return bug with GetHandleId now, no other return bugs work, except S2I.

Now, how to work around the return bug not working anymore? Hashtables. Store it something like: Parent(PlayerId), Child(SomeInteger) and retrieve the same way.

H2I/GetHandleId

Replace parts of H2I to return the native instead:

JASS:
function H2I takes handle h returns integer
    return h
    //call DoNothing()  &lt;-- Probably won&#039;t be in peoples&#039; maps, but just in case it is, so you don&#039;t go &quot;OMG? WHERE R H2I???&quot; <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />
    return 0
endfunction


becomes

JASS:
function H2I takes handle h returns integer
    return GetHandleId(h)
endfunction


JassHelper will turn this:

JASS:
local integer i = H2I(GetTriggerUnit())


into:



Via inlining.

And that's about it for the return bug ;)

Else Return Bug

As of 1.24b, there are no more false positives on this. (There shouldn't be, at least.) However, it's still safe to follow your good sense and try to avoid these situations.

Conclusion

Congratulations! Your map is 1.24b compatible!

Or, not. And you failed somewhere. :rolleyes: (There aren't many places you can screw up anymore >_>) Start at the beginning again.

If anyone finds anything new that pops up and needs fixing, post here so I can add it/fix it ;)
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
...o.o'. The elseif bug only applies if they return mid trigger. I have about 7 elseif's, the same exact format, working fine.
 

Sevion

The DIY Ninja
Reaction score
413
As I said, it's just a fail-safe method :rolleyes: If you know it's not going to bug, then don't change it ;)
 

Jesus4Lyf

Good Idea™
Reaction score
397
JASS:
elseif i &gt; 11 then
    call KillUnit(u)
endif


becomes

JASS:
endif
if i &gt; 11 then
    call KillUnit()
endif


While it may seem unnecessary to change all of them, it just is a fail-safe.
How is that failsafe? That is wrong.

Anyway, the real answer is if you use "return" in an "if" block, follow it immediately with "endif". There is no reason not to, and it fixes the bug basically.
 

Sevion

The DIY Ninja
Reaction score
413
If anyone finds anything new that pops up and needs fixing, post here so I can add it/fix it

:rolleyes:

It'd help if you gave more details as to why it's wrong and how to fix it.
 

Sevion

The DIY Ninja
Reaction score
413
JASS:
if i==1 then
    dostuff
elseif 1==0 then
    dostuff
endif


Does the same as

JASS:
if i==1 then
    dostuff
endif
if i==0 then
    dostuff
endif


Right?
 

Jesus4Lyf

Good Idea™
Reaction score
397
JASS:
if i==1 then
    dostuff
endif
if i!=1 and i==0 then
    dostuff
endif

That will (for this example it didn't matter, but to be generally applicable it must be done like this).

Edit: But this is stupid. This isn't the problem to begin with. Please don't go tell people to remove all "else", it's insanity.
 

Sevion

The DIY Ninja
Reaction score
413
It's just a method. :rolleyes:

How is this not the problem. You have to convert all your stuff to 1.24 anyhow (not you, but others)

And using returns in a way that most systems/maps w/e do, will cause bugs. Thus, doing this will remove the bugs -_-'

elseif portion fixed.
 

Jesus4Lyf

Good Idea™
Reaction score
397
the real answer is if you use "return" in an "if" block, follow it immediately with "endif". There is no reason not to, and it fixes the bug
May I beg you to teach people the correct answer instead?

It is also the correct way to write the code, this never should've been an issue. "return else" is stupid because anything after "return endif" is "else" anyway.

Edit: You STILL screwed up the elseif section. This is ridiculous. :(
 

quraji

zap
Reaction score
144
But
JASS:
if i==1 then
    call A()
else
    call B()
endif

is not the same as
JASS:
if i==1 then
    call A()
endif
call B()

Taken directly from your tutorial.

The if/else/elseif part of your tutorial is just messy and wrong. Address the actual bug instead of just telling people to do random things as a 'fail-safe'.

And, instead of replacing every H2I call with GetHandleId, I'd just change the actual H2I function to this:
JASS:
function H2I takes handle h returns integer
return GetHandleId(h)
endfunction

It's much easier, and vJass will inline it anyways. And when (if) Blizzard does release their own H2I, you can just delete it and still not have to change anything in the code.

Anyways, this is easily useful to people, so good job (after fixes).
 

Sevion

The DIY Ninja
Reaction score
413
>H2I

Heard somewhere Blizzard planned on making an H2I function. If this is true, it may bug o_O'

Besides, I forgot that JassHelper would inline that >=O

>if/else/elseif

Wrote this in like 3 minutes :eek:
 

Sevion

The DIY Ninja
Reaction score
413
I suggest you don't post a tutorial if you wrote it in 3 minutes then, or as is evident...you'll be eaten alive :eek:

Makes it easier for me to A) learn B) proof the tutorial ;)

I learn a lot better this way as when I do something quickly, then find out it was wrong, it helps me learn XD I learn to do things right the first time around that way. (That's just how I learn o_O')
 

quraji

zap
Reaction score
144
Makes it easier for me to A) learn B) proof the tutorial ;)

I learn a lot better this way as when I do something quickly, then find out it was wrong, it helps me learn XD I learn to do things right the first time around that way. (That's just how I learn o_O')

Well that's fine, if you can take criticism :p

The updated tutorial looks pretty solid, although some more explanation might be nice. Like how vJass will inline GetHandleId in the edited H2I. And, what exactly the bug is with the double returns, and returns in ifs. This will help anyone that doesn't know understand, and it will show you have a reason for the changes, instead of just pulling them out of a hat :D
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
My solution for elseif's was to set a local variable and return it at the end, setting the variables in the elseif's. But that's only one solution, yet there's many more methods of working with elseif's with different solutions.
 

Sevion

The DIY Ninja
Reaction score
413
Well that's fine, if you can take criticism :p

The updated tutorial looks pretty solid, although some more explanation might be nice. Like how vJass will inline GetHandleId in the edited H2I. And, what exactly the bug is with the double returns, and returns in ifs. This will help anyone that doesn't know understand, and it will show you have a reason for the changes, instead of just pulling them out of a hat :D

Done ;)

Ren, will add your solution.
 

quraji

zap
Reaction score
144
I'd put H2I in a separate section than Return Bug, since it no longer uses the return bug (and to make it easier to read). Oh, and in your H2I function I'd take out the DoNothing() call, since it probably won't be there in peoples' maps =]
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top