ScriptUO

Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: xenoglyph on August 23, 2009, 01:50:40 AM

Title: how to convert EUO IDs to decimal?
Post by: xenoglyph on August 23, 2009, 01:50:40 AM
say for instance I have an EUO id of XG or YG, how do i convert that to an integer?  it's not base 26.
Title: Re: how to convert EUO IDs to decimal?
Post by: TrailMyx on August 23, 2009, 01:56:57 AM
lemme look around, I have a couple routines written that does the conversion.
Title: Re: how to convert EUO IDs to decimal?
Post by: TrailMyx on August 23, 2009, 02:00:16 AM
Here's something I came up with; Boydon gave me the original code:

Code: [Select]
        private string hex2euo(int hexid)
        {
        string rval = "";
       
        for (int i = (hexid ^ 0x45) + 7; i > 0; i /= 26)
        rval += (char)((i % 26) + 'A');

        return rval;
        }
       
        private int euotohex(string euoid)
        {
        int hexid = 0;
       
        for (int j=0, i = 1; j<euoid.Length; j++ , i *= 26)
        hexid += (int)(euoid[j] - 'A') * i;

        hexid = (hexid - 7) ^ 0x45;
        return hexid;
        }
Title: Re: how to convert EUO IDs to decimal?
Post by: xenoglyph on August 23, 2009, 02:17:05 AM
hell yah, thanks! that was fast.
Title: Re: how to convert EUO IDs to decimal?
Post by: TrailMyx on August 23, 2009, 02:20:10 AM
Heh, I already plugged them into your code when I was playing.  ;)