"My map worked on westfall but not on 1.24"

T.s.e

Wish I was old and a little sentimental
Reaction score
133
This is the code for testing H2I with DoNothing():
JASS:
function H2I takes handle h returns integer
return h
call DoNothing()
return 0
endfunction

function Trig_H2ITest_Actions takes nothing returns nothing
local unit u = CreateUnit(Player(0), 'hfoo', 0,0,270)
call BJDebugMsg("H2I         : " + I2S(H2I(u)))
call BJDebugMsg("GetHandleID : " + I2S(GetHandleId(u)))
set u= null
endfunction

//===========================================================================
function InitTrig_H2ITest takes nothing returns nothing
    set gg_trg_H2ITest = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_H2ITest, 5 )
    call TriggerAddAction( gg_trg_H2ITest, function Trig_H2ITest_Actions )
endfunction
 

Sevion

The DIY Ninja
Reaction score
413
i didn't know there were 10000 resources , i fixed my map, though it still doesn't completely work, but blizzard needs to simply make the compiler look at all return statements, and see if they return the correct type, wouldn't that work better?

Why would there need to be exactly 10k resources for 99.99%?
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
99.99% != 10000

... fail math?

if you have 100 resources and one breaks, 99% still work.
if you have 1000 resources and one breaks, 99.9% still work.
if you have 10000 resources and one breaks, 99.99% still work.

You need to have 10,000 or more resources to accurately say 99.99%. He was being a smarta$$ but you still failed at math...
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
[del]i didn't know there were 10000 resources , [/del]i fixed my map, though it still doesn't completely work, but blizzard needs to simply make the compiler look at all return statements, and see if they return the correct type, wouldn't that work better?

The blizzard compiler does do that, NewGens does not. :p

I was saying he thought it was 9,999.

I don't recall him ever saying that. He was saying that you need at least 10,000 to be able to use .0X%'s
 

Jesus4Lyf

Good Idea™
Reaction score
397
>blizzard needs to simply make the compiler look at all return statements, and see if they return the correct type
The blizzard compiler does do that
Do you not know about the return bug? or...

The WC3 JASS compiler does not check each return type. We're not talking about the default World Editor syntax checker, but WC3's internal compiler.
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
Yea, I misread that. I thought he was looking for his last few if statements that don't return on the last else/elseif. The blizzard compiler finds those even though they aren't a bug :|
 

MasterOfRa

New Member
Reaction score
10
i know newgen doesn't, and blizzard did not do it the way i said, because if they did, the return bug wouldn't be still possible like this....

JASS:
function H2I takes handle h returns integer
return h
call DoNothing()
return 0
endfunction

if they did it my way, it would look at the return h and say that that isnt a integer, and it wouldn't work. they did it differently, and it mest up alot of maps because of the if elseif return bug that makes this not work
JASS:
if true then
    return true
elseif true
endif
return true

Also, i was already saying that for there to be 99.99% of them not working, there would have to be a multiple of 10000, (not 9999, look at the coma) I was being sarcastic...
Do you not know about the return bug? or...

The WC3 JASS compiler does not check each return type. We're not talking about the default World Editor syntax checker, but WC3's internal compiler.
The blizzard compiler does do that, NewGens does not. :p
I was talking about WC3's internal compiler anyway... newgen still doesn't have a problem with you useing the return bug, and it doesn't need to until they fix the bug completely
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Another update, If you use a return in ANY of the IF BLOCKS OR ELSEIF BLOCKS (excluding the last ELSEIF block) then the last ELSEIF must return.

JASS:
function Hi takes integer i returns real  // DOES NOT WORK
    local real r
    if i > 1 then
        set r = 5
    elseif i > 2 then
        set r = 6.
        return r
    elseif i > 3 then
        set r = 6.
    elseif i > 4 then
        set r = 7.
    endif
    return 0.
endfunction


JASS:
function Hi takes integer i returns real  // WORKS
    local real r
    if i > 1 then
        set r = 5
    elseif i > 2 then
        set r = 6.
        return r
    elseif i > 3 then
        set r = 6.
    elseif i > 4 then
        set r = 7.
        return r
    endif
    return 0.
endfunction


BTW: these only show what will LOAD the map, it will still probably Critical error after map loads.

So wait, if i've understood all your tests, test if the map is loading is not enough ?
We have to test the code if it doesn't crash war3 when it is executed ?!

Also i just want to point out that you need to test it with debug mode "on" and "off" (ofc if you use vJass), because sometimes it does matter.
.
 

cleeezzz

The Undead Ranger.
Reaction score
268
exactly so theres no point of even trying to fix it by returning in the last endif,

separate them into 2 separate IFs and use a local boolean if you must.
 

Romek

Super Moderator
Reaction score
963
More retarded stuff:
JASS:
   // Works:
        if not <condition> then
            set u = null
           // return false
        else
            set bool = false
            call function()
        endif

   // Works:
        if not <condition> then
            set u = null
            return false
        endif
        if <same condition> then
            set bool = false
            call function()
        endif

   // Doesn't Load Map:
        if not <condition> then
            set u = null
            return false
        else
            set bool = false
            call function()
        endif


JASS:
   // Works:
    function Test takes nothing returns boolean
        local unit u = null
        if false then
            set u = null
            return false
        else
        endif
        return false
    endfunction


    // Crashes:
    function Test takes nothing returns boolean
        local unit u = null
        if false then
            set u = null
            return false
        else
            set u = null
        endif
        return false
    endfunction


The first set of stuff was taken from a script I'm working on, with the condition replaced and stuff. So the result could be caused by something similar to that.

The second was me testing to find the cause of the first.

Edit:
JASS:
// Crash:
   function Test takes nothing returns boolean
        local unit u
        if true then
            return false
        else
            set u = null
        endif
        return false
    endfunction

// Work:
   function Test takes nothing returns boolean
        local unit u
        if true then
            return false
        else
            //set u = null
        endif
        return false
    endfunction
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
My general rule:

If you return in an "if" statement, follow it immediately with "endif". There's no point in using an "else" anyway, just costs more lines of code. Everything after the "endif" is "else" anyway.

So for that reason, I'm glad for this bug. :)
Seems enough fair if it is true in all cases, is it ?

Also yes there is no point of using else but elseif save one line code (no endif) xD
And yes i know the bytecode should be exactly the same.
 

SerraAvenger

Cuz I can
Reaction score
234
can anyone explain to me why this function doesn't load?

JASS:
function GetClosestUnitInRange takes real x, real y, real radius, boolean closest, boolexpr filter returns unit
    local group g = GLOBAL_GROUP
    local unit curUnit = null
    local unit loopUnit
    local real curDist
    local real dX
    local real dY
    local real loopDist
    call GroupClear( g )
    call GroupEnumUnitsInRange( g, x, y, radius, filter )
    if closest then
        set curDist = radius + 1
    else
        set curDist = 0
    endif
    loop
        set loopUnit = FirstOfGroup( g )
        exitwhen loopUnit == null
        set dX = x - GetUnitX( loopUnit )
        set dY = y - GetUnitY( loopUnit )
        set loopDist = SquareRoot( dX * dX + dY * dY )
        if loopDist < curDist == closest then
            set curDist = loopDist
            set curUnit = loopUnit
        endif
        call GroupRemoveUnit( g, loopUnit )
    endloop
    set ReturnHandle = curUnit
    set filter = null
    set loopUnit = null
    set curUnit = null
    return ReturnHandle
endfunction
 

SerraAvenger

Cuz I can
Reaction score
234
serra i dont see anything wrong with that trigger, are you sure its that code?

yes, I commented it out and the map loaded.
If I have the function in the map, it doesn't even show the correct player slots in the lobby when selecting it in single player.

I don't see anything wrong with it either...

Thanks for your comments, Serra
 
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