Not sure how to use this with the new patch.

Terrabull

Veteran Member (Done that)
Reaction score
38
I have a bit of code that uses the return bug, but it doesn't really use the handle ID, so I can't use that native.
Can anyone help me figure out a way to fix this so it works in the new version.
JASS:
function GetPlayerColorID takes player p returns integer
    return GetPlayerColor(p)
    return 0
endfunction
 

Tom Jones

N/A
Reaction score
437
I have a bit of code that uses the return bug, but it doesn't really use the handle ID, so I can't use that native.
Can anyone help me figure out a way to fix this so it works in the new version.
JASS:
function GetPlayerColorID takes player p returns integer
    return GetPlayerColor(p)
    return 0
endfunction
Why not?
JASS:
type playercolor        extends     handle

native GetPlayerColor takes player whichPlayer returns playercolor

function GetPlayerColorId takes player p returns integer
    return GetHandleId(GetPlayerColor(p))
endfunction
 

Terrabull

Veteran Member (Done that)
Reaction score
38
You need to get list of color constants....
I was hoping for some automatic way.

There's already a built in function to do exactly what you're doing. Just use ConvertPlayerColor(GetPlayerColor(p)).
I looked at that. That native converts and integer into a playercolor, not the other way around (which is what I'm doing).

I was thinking about that, but wouldn't that give the ID of the handle, and not the value? A playercolor is essentially an integer constant, I just need to recast the type.

+rep for fast replies. :)
 

Tom Jones

N/A
Reaction score
437
I know that it's an integer constant, and I'm fairly certain it'll return that constant.
 

jwallstone

New Member
Reaction score
33
Did you test it out? Does it return the correct integer constant?

If so, that behavior from GetHandleId is kind of messy. A lot of different non-agent handles are just integer constants, and if GetHandleId just returns that integer, then I can see a lot of people trying to use this and having conflicts.
 

jwallstone

New Member
Reaction score
33
Test results: GetHandleId does return the actual integer value of a PlayerColor.

Assuming this applies to all the non-agent handles, this should be a point of warning for anyone using GetHandleId on such handles for the purposes of getting a hashtable index, for example.
 
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