Orderid base.

Tom Jones

N/A
Reaction score
437
So this thread made me wonder:

What base are orderids? Or are they even part of a base system?

I can't come up with any results whatsoever, this is what I've used to test:
JASS:
function S2Hex takes string value, integer base returns integer
    local string map = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ "
    local string first 
    local string s 
    local integer i = 0
    local integer a = 0
    local integer hex = R2I(Pow(base,StringLength(value)-1))
    local integer result = 0
    
    loop
        set first = SubString(value,i,i+1)
        exitwhen first == ""
        set a = 0
        loop
            set s = SubString(map,a,a+1)
            exitwhen s == ""
            if s == first then
                set result = result+((a+32)*hex)
                set hex = hex/base
                exitwhen true
            endif
            set a = a+1
        endloop
        set i = i+1
    endloop
    return result
endfunction

function Hex2S takes integer value, integer base returns string
    local string map = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ "
    local integer i = value
    local integer a = 0
    local string result = ""
    
    loop
        set a = (i-(i/0x100)*base)-32
        set i = i/base
        set result = SubString(map,a,a+1)+result
        exitwhen i <= 1
    endloop
    return result
endfunction
    
function Trig_Test_Actions takes nothing returns nothing
    local string s = "slow"
    local integer base = 2
    local integer id = OrderId(s)

    call BJDebugMsg("OrderID = "+I2S(id))
    loop
        exitwhen base > 256 or S2Hex(s,base) > id
        call BJDebugMsg("Calculated OrderID = "+I2S(S2Hex(s,base)))
        set base = base+2
    endloop
    call BJDebugMsg("Base = "+I2S(base))

endfunction

//===========================================================================
function InitTrig_Test takes nothing returns nothing
    set gg_trg_Test = CreateTrigger(  )
    //call TriggerRegisterPlayerChatEvent( gg_trg_Test, Player(0), "test", true )
    call TriggerRegisterTimerEvent(gg_trg_Test,1,false)
    call TriggerAddAction( gg_trg_Test, function Trig_Test_Actions )
endfunction
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
You are confusing order strings with order ids.

Remember, "the base system" is just a way to write a number in a more convenient way. Integers doesn't have a base, they are just numbers. When we convert the number to a string it's converted with base 10 digits and when we enter the number in the world editor we can choose between base 8, 10, 16 or 256. For ability ids we type in base 256, mostly because blizzard decided that base 256 was a nice way to "name" ability ids. For orders, blizzard took another approach and let us order units using strings instead but for some reason not all orders can be given with strings to there is also the order id which is usually written in base 10... Order strings and order ids have nothing in common afaik except that they can be used to order the same thing.
 

Tom Jones

N/A
Reaction score
437
I'm not confusing the two, I'm just trying to find the connection. I came to the conclusion, that if:

JASS:
function ...
    local integer id = OrderId("slow")
endfunction
is able to convert the string to an integer, so can we. It's that conversion I'm interested in, since, as far as I can tell, it doesn't use base conversion. Perhaps it uses a conversion that includes it's base ability in some way, which would be really interesting, because then we could get orderids out of abilityids. All this is just speculation, I have as mentioned in the first post no clue about what's going on.
 

Strilanc

Veteran Scripter
Reaction score
42
I'm not confusing the two, I'm just trying to find the connection. I came to the conclusion, that if:

JASS:
function ...
    local integer id = OrderId("slow")
endfunction
is able to convert the string to an integer, so can we. It's that conversion I'm interested in, since, as far as I can tell, it doesn't use base conversion. Perhaps it uses a conversion that includes it's base ability in some way, which would be really interesting, because then we could get orderids out of abilityids. All this is just speculation, I have as mentioned in the first post no clue about what's going on.

The conversion is arbitrary. It probably uses a hash table. If they renamed a spell, they wouldn't have to change the base id.
 

Strilanc

Veteran Scripter
Reaction score
42
here is such a table .. :)

I seem to have misunderstood the question. I thought he wanted a simple algorithm to turn ability names into ability IDs. Apparently he wanted ability IDs to order IDs.

In that case I wouldn't be surprised if they were identical (to make parsing orders easier), and I wouldn't be surprised if they were not identical (to make future compatibility easier).
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top