• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Return Bug

Status
Not open for further replies.
Level 9
Joined
Jul 4, 2007
Messages
130
I know these kinds of function uses the return bug and makes the game unplayable:
JASS:
function H2I takes handle h returns integer
    return h
    return 0
endfunction

but how about this:
JASS:
function H2I takes handle h returns integer
if 1 > udg_whatevernumber then
    return 1
endif
    return 2
endfunction

does it still fuck the map to have 2 return ? (or more)
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
No, also this function is fine.

JASS:
function Test takes nothing returns integer
    return 0
    return 0
endfunction
 
JASS:
function H2I takes handle h returns integer
if 1 > udg_whatevernumber then
    return 1
endif
    return 2
endfunction

does it still fuck the map to have 2 return ? (or more)
Do you even know what you are talking about? This example did always work and will always work and has nothing to do with the return bug Oo
And this doesn't even convert handle to int ...

And besides: H2I can now be replaced by GetHandleId(handle)
 
@Vortigon, what you're trying to archieve with second script? It even doesn't use passed handle parameter.

Anyways, script you have shown has two 'returns' in two differend places.
JASS:
function H2I takes handle h returns integer
if 1 > udg_whatevernumber then
    return 1 // #1
endif
    return 2 // #2
endfunction
You have to understand that whenever function sees keyword 'return' it automaticaly skips all actions remaining. So there is nothing wrong with the code, although you could elaborate the subject.
And yes, as said already: to 'convert' handle to integer nowadays we can just use: local integer i = GetHandleId(somehandle)
 
so there is no problem if i have 2 or more return of the same type in a function ?
The map won't be unplayable?
Of course not. It never was like that and will never be as this is one of a basic principles of programming.

and I know what a return is and the return bug as well thanks.
No you obviously don't. The return bug was not a bug because of the double return, but because of the way it was used to disguise a different return parameter as an integer althought it never was an integer in the first place.
 
Level 9
Joined
Jul 4, 2007
Messages
130
Dont be so unpolite, I know well that multiple returns are used a lot in programming, as well as I know what the return bug is, what I only asked for is to know if Blizzard fixed this bug by making multiple returns in a function result in an unplayable map, ignoring if it was even used to convert a data type to another.

anyways I got my answer thanks.
 
Status
Not open for further replies.
Top