Thread: jagex ident table class

Page 1 of 3 123 LastLast
Results 1 to 10 of 21
  1. #1 jagex ident table class 
    Renown Programmer
    veer's Avatar
    Join Date
    Nov 2007
    Posts
    3,746
    Thanks given
    354
    Thanks received
    1,370
    Rep Power
    3032
    Code:
    // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
    // Jad home page: http://www.kpdus.com/jad.html
    // Decompiler options: packimports(3) 
    
    
    final class Class163
    {
    
        public static void method2295(int i)
        {
            try
            {
                if(i != 99)
                {
                    return;
                } else
                {
                    aBooleanArrayArray2285 = null;
                    anIntArray2284 = null;
                    return;
                }
            }
            catch(RuntimeException runtimeexception)
            {
                throw Class130_Sub1.method1251(runtimeexception, "qq.C(" + i + ')');
            }
        }
    
        static final void method2296(Class35 class35, Class138_Sub13 class138_sub13, int i, boolean flag)
        {
            try
            {
                Class138_Sub34 class138_sub34 = new Class138_Sub34();
                class138_sub34.anInt4488 = class138_sub13.method1382((byte)104);
                class138_sub34.anInt4477 = class138_sub13.method1381(-20);
                if(!flag)
                    aBoolean2276 = false;
                class138_sub34.aByteArrayArrayArray4481 = new byte[class138_sub34.anInt4488][][];
                class138_sub34.anIntArray4489 = new int[class138_sub34.anInt4488];
                class138_sub34.anIntArray4484 = new int[class138_sub34.anInt4488];
                class138_sub34.aClass206Array4487 = new Class206[class138_sub34.anInt4488];
                class138_sub34.aClass206Array4476 = new Class206[class138_sub34.anInt4488];
                class138_sub34.anIntArray4485 = new int[class138_sub34.anInt4488];
                for(int j = 0; j < class138_sub34.anInt4488; j++)
                    try
                    {
                        int k = class138_sub13.method1382((byte)104);
                        if(~k != -1 && k != 1 && ~k != -3)
                        {
                            if(k == 3 || ~k == -5)
                            {
                                String s = class138_sub13.method1410((byte)114);
                                String s2 = class138_sub13.method1410((byte)123);
                                int l = class138_sub13.method1382((byte)104);
                                String as[] = new String[l];
                                for(int j1 = 0; l > j1; j1++)
                                    as[j1] = class138_sub13.method1410((byte)116);
    
                                byte abyte0[][] = new byte[l][];
                                if(~k == -4)
                                {
                                    for(int k1 = 0; l > k1; k1++)
                                    {
                                        int l1 = class138_sub13.method1381(-20);
                                        abyte0[k1] = new byte[l1];
                                        class138_sub13.method1359(!flag, l1, abyte0[k1], 0);
                                    }
    
                                }
                                class138_sub34.anIntArray4489[j] = k;
                                Class aclass[] = new Class[l];
                                for(int i2 = 0; l > i2; i2++)
                                    aclass[i2] = Class157_Sub1.method2166((byte)-71, as[i2]);
    
                                class138_sub34.aClass206Array4487[j] = class35.method350(s2, Class157_Sub1.method2166((byte)-71, s), aclass, false);
                                class138_sub34.aByteArrayArrayArray4481[j] = abyte0;
                            }
                        } else
                        {
                            String s1 = class138_sub13.method1410((byte)66);
                            String s3 = class138_sub13.method1410((byte)117);
                            int i1 = 0;
                            if(k == 1)
                                i1 = class138_sub13.method1381(-16);
                            class138_sub34.anIntArray4489[j] = k;
                            class138_sub34.anIntArray4485[j] = i1;
                            class138_sub34.aClass206Array4476[j] = class35.method334(9236, s3, Class157_Sub1.method2166((byte)-71, s1));
                        }
                    }
                    catch(ClassNotFoundException _ex)
                    {
                        class138_sub34.anIntArray4484[j] = -1;
                    }
                    catch(SecurityException _ex)
                    {
                        class138_sub34.anIntArray4484[j] = -2;
                    }
                    catch(NullPointerException _ex)
                    {
                        class138_sub34.anIntArray4484[j] = -3;
                    }
                    catch(Exception _ex)
                    {
                        class138_sub34.anIntArray4484[j] = -4;
                    }
                    catch(Throwable _ex)
                    {
                        class138_sub34.anIntArray4484[j] = -5;
                    }
    
                Class138_Sub35_Sub29.aClass115_6322.method1150(-104, class138_sub34);
                return;
            }
            catch(RuntimeException runtimeexception)
            {
                throw Class130_Sub1.method1251(runtimeexception, "qq.A(" + (class35 == null ? "null" : "{...}") + ',' + (class138_sub13 == null ? "null" : "{...}") + ',' + i + ',' + flag + ')');
            }
        }
    
        Class163(int ai[])
        {
            try
            {
                int i;
                for(i = 1; ai.length + (ai.length >> 1) >= i; i <<= 1);
                anIntArray2278 = new int[i + i];
                for(int j = 0; ~(i - -i) < ~j; j++)
                    anIntArray2278[j] = -1;
    
                for(int k = 0; ~k > ~ai.length; k++)
                {
                    int l;
                    for(l = -1 + i & ai[k]; ~anIntArray2278[(l + l) - -1] != 0; l = l + 1 & -1 + i);
                    anIntArray2278[l + l] = ai[k];
                    anIntArray2278[l - (-l - 1)] = k;
                }
    
                return;
            }
            catch(RuntimeException runtimeexception)
            {
                throw Class130_Sub1.method1251(runtimeexception, "qq.<init>(" + (ai == null ? "null" : "{...}") + ')');
            }
        }
    
        final int method2297(int i, int j)
        {
            try
            {
                int k = (anIntArray2278.length >> 1) + -1;
                int l = k & i;
                do
                {
                    int i1 = anIntArray2278[1 + l + l];
                    if(~i1 == 0)
                        return -1;
                    if(~anIntArray2278[l + l] == ~i)
                        return i1;
                    l = k & 1 + l;
                } while(true);
            }
            catch(RuntimeException runtimeexception)
            {
                throw Class130_Sub1.method1251(runtimeexception, "qq.B(" + i + ',' + j + ')');
            }
        }
    
        static int anInt2273 = 0;
        static int anInt2274;
        static boolean aBoolean2275 = false;
        static boolean aBoolean2276 = true;
        static int anInt2277 = 0;
        private int anIntArray2278[];
        static int anInt2279 = 127;
        static int anInt2280 = 0xf423f;
        static int anInt2281;
        static int anInt2282;
        static int anInt2283;
        static int anIntArray2284[] = {
            99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 
            99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 
            99, 99, 99, 99, 99
        };
        static boolean aBooleanArrayArray2285[][] = {
            {
                true, true, true, true, true, true, true, true, true, true, 
                true, true, true
            }, {
                true, true, true, false, false, false, true, true, false, false, 
                false, false, true
            }, {
                true, false, false, false, false, true, true, true, false, false, 
                false, false, false
            }, {
                false, false, true, true, true, true, false, false, false, false, 
                false, false, false
            }, {
                true, true, true, true, true, true, false, false, false, false, 
                false, false, false
            }, {
                true, true, true, false, false, true, true, true, false, false, 
                false, false, false
            }, {
                true, true, false, false, false, true, true, true, false, false, 
                false, false, true
            }, {
                true, true, false, false, false, false, false, true, false, false, 
                false, false, false
            }, {
                false, true, true, true, true, true, true, true, false, false, 
                false, false, false
            }, {
                true, false, false, false, true, true, true, true, true, true, 
                false, false, false
            }, {
                true, true, true, true, true, false, false, false, true, true, 
                false, false, false
            }, {
                true, true, true, false, false, false, false, false, false, false, 
                true, true, false
            }, new boolean[13]
        };
    
    }
    ok lets do some manual deobfuscation:
    Code:
    class Class163 {
    
        Class163(int ai[]) {
            int i;
            for(i = 1; ai.length + (ai.length >> 1) >= i; i <<= 1);
            anIntArray2278 = new int[i + i];
            for(int j = 0; i + i > j; j++) {
                anIntArray2278[j] = -1;
            }
    
            for(int k = 0; k < ai.length; k++) {
                int l;
                for(l = ai[k] & i - 1; anIntArray2278[l + l + 1] != -1; l = l + 1 & i - 1);
                anIntArray2278[l + l] = ai[k];
                anIntArray2278[l + l + 1] = k;
            }
    
            return;
        }
    
        final int method2297(int i) {
            int k = (anIntArray2278.length >> 1) + -1;
            int l = k & i;
            do {
                int i1 = anIntArray2278[1 + l + l];
                if(i1 == -1)
                    return -1;
                if(anIntArray2278[l + l] == i)
                    return i1;
                l = k & 1 + l;
            } while (true);
        }
    
        private int[] anIntArray2278;
    }
    lets look at the constructor:
    Code:
        Class163(int ai[]) {
            int i;
            for(i = 1; ai.length + (ai.length >> 1) >= i; i <<= 1);
            anIntArray2278 = new int[i + i];
            for(int j = 0; i + i > j; j++) {
                anIntArray2278[j] = -1;
            }
    
            for(int k = 0; k < ai.length; k++) {
                int l;
                for(l = ai[k] & i - 1; anIntArray2278[l + l + 1] != -1; l = l + 1 & i - 1);
                anIntArray2278[l + l] = ai[k];
                anIntArray2278[l + l + 1] = k;
            }
    
            return;
        }
    ai is the list of idents indexed by file num. the next lines find a value of i such that i is a multiple of two and is greater than or equal to 1.5 times the size of the input. by doing this, it is ensuring a 2:3 ratio between elements and capacity, or a load factor of about 67%, which averages at approximately 2/3 cache misses per lookup, which continues to grow and eventually skyrockets after 80%:

    number of misses means more probes/searches, which means speed loss... and speed is a big factor.
    the next lines create and clear the bucket array. you might notice it initializes it to twice the capacity. the reason of this is because it also stores the key, or ident in this case, along with the value, or file num in this case.
    lets look at the big loop...
    it loops through each element of input and then does the following funky loop:
    Code:
                for(l = ai[k] & i - 1; anIntArray2278[l + l + 1] != -1; l = l + 1 & i - 1);
    what's this doing? simple... linear probing with a step size of one.

    TO BE CONTINUED

    credits to wikipedia for image
    Reply With Quote  
     

  2. #2  
    Renown Programmer
    veer's Avatar
    Join Date
    Nov 2007
    Posts
    3,746
    Thanks given
    354
    Thanks received
    1,370
    Rep Power
    3032
    ps its called an open addressed hash table
    Reply With Quote  
     

  3. #3  
    Renown Programmer
    veer's Avatar
    Join Date
    Nov 2007
    Posts
    3,746
    Thanks given
    354
    Thanks received
    1,370
    Rep Power
    3032
    alsoooooooooo, if you have no clue as to what this is for, its the class which is instantiated during ref table parsing, and its usage is like:
    class_inst.method("um" + r_x + "_" + r_y);
    and converts the string to a file num/idx
    Reply With Quote  
     

  4. #4  
    Banned

    Join Date
    Sep 2006
    Age
    31
    Posts
    3,019
    Thanks given
    22
    Thanks received
    420
    Rep Power
    0
    Quote Originally Posted by super_ View Post
    alsoooooooooo, if you have no clue as to what this is for, its the class which is instantiated during ref table parsing, and its usage is like:
    class_inst.method("um" + r_x + "_" + r_y);
    and converts the string to a file num/idx
    This post made me go from ? to I see after reading the first post lol.

    Good job.
    Reply With Quote  
     

  5. #5  
    Java/C++ Programmer

    Join Date
    Jun 2008
    Age
    27
    Posts
    1,377
    Thanks given
    203
    Thanks received
    387
    Rep Power
    815
    good job bro
    Reply With Quote  
     

  6. #6  
    LastMessage
    Guest
    Quote Originally Posted by Palidino76 View Post
    This post made me go from ? to I see after reading the first post lol.

    Good job.
    lol
    Quote Originally Posted by Lazaro View Post
    good job bro
    you are an idiot

    i+i==initial size?
    -1==indicates the space is empty


    Code:
        final int method2297(int i) {
            int k = (anIntArray2278.length >> 1) + -1;
            int l = k & i;//starting index, might initially be the index 
            do {
                int i1 = anIntArray2278[1 + l + l];//value?
                if(i1 == -1)//empty
                    return -1;
                if(anIntArray2278[l + l] == i)//found
                    return i1;
                l = k & 1 + l;//increase the index
            } while (true);
        }
    in here anIntArray2278[l + l] is the key whilst l+l+1 is the value associated with the key? didnt read the bottom

    also wouldnt double hashing prove faster? i used double hashing in my hashmap, was pretty fast, my initial size was always a prime number calculated from the specified size

    also you might be interested in: http://eigenclass.org/R2/writings/se...double-hashing

    ~Light232
    Reply With Quote  
     

  7. #7  
    Registered Member

    Join Date
    Jun 2007
    Age
    29
    Posts
    3,003
    Thanks given
    52
    Thanks received
    98
    Rep Power
    3208
    have you refactored it yet?
    Reply With Quote  
     

  8. #8  
    LastMessage
    Guest
    Quote Originally Posted by Simon View Post
    have you refactored it yet?
    its self explanatory
    Reply With Quote  
     

  9. #9  
    Renown Programmer
    veer's Avatar
    Join Date
    Nov 2007
    Posts
    3,746
    Thanks given
    354
    Thanks received
    1,370
    Rep Power
    3032
    Quote Originally Posted by LastMessage View Post
    lol

    you are an idiot

    i+i==initial size?
    -1==indicates the space is empty


    Code:
        final int method2297(int i) {
            int k = (anIntArray2278.length >> 1) + -1;
            int l = k & i;//starting index, might initially be the index 
            do {
                int i1 = anIntArray2278[1 + l + l];//value?
                if(i1 == -1)//empty
                    return -1;
                if(anIntArray2278[l + l] == i)//found
                    return i1;
                l = k & 1 + l;//increase the index
            } while (true);
        }
    in here anIntArray2278[l + l] is the key whilst l+l+1 is the value associated with the key? didnt read the bottom

    also wouldnt double hashing prove faster? i used double hashing in my hashmap, was pretty fast, my initial size was always a prime number calculated from the specified size

    also you might be interested in: http://eigenclass.org/R2/writings/se...double-hashing

    ~Light232
    i+i is the capacity... the final size. notice there is no threshold... this is because it has a constant # of buckets and will never need to be resized.
    anyway, i havent looked into double hashing much, but iirc it's linear probing with a step size resolved from a hash function.
    [l+l] is the key while [l + l + 1] is the value. anyway, your initial size does not matter, as long as the load factor isn't too high and lookups begin to be costly.
    anyway
    Code:
    final int get(int key) {
        /*
         * divide length by 2 because of the fact bkts contains
         * keys and vals. subtract 1 so that modulus can be
         * optimized into bitwise and.
         */
        int len = (bkts.length >> 1) - 1;
        /*
         * linear probing!
         * note: a & b - 1 where b % 2 == 0 -> a % b
         */
        int probe_idx = key & len;
        do {
            int val = bkts[probe_idx + probe_idx + 1];
            /* did we reach the end of our table? */
            if (val == -1) {
                return -1;
            }
            /* have we found our key? */
            if (bkts[probe_idx + probe_idx] == key) {
                return val;
            }
            /* 
             * linear probing: NEXT!
             * note: step size of 1
             */
            probe_idx = key & probe_idx + 1;
        } while (true);
    }
    Reply With Quote  
     

  10. #10  
    LastMessage
    Guest
    Quote Originally Posted by super_ View Post
    i+i is the capacity... the final size. notice there is no threshold... this is because it has a constant # of buckets and will never need to be resized.
    anyway, i havent looked into double hashing much, but iirc it's linear probing with a step size resolved from a hash function.
    [l+l] is the key while [l + l + 1] is the value. anyway, your initial size does not matter, as long as the load factor isn't too high and lookups begin to be costly.
    anyway
    Code:
    final int get(int key) {
        /*
         * divide length by 2 because of the fact bkts contains
         * keys and vals. subtract 1 so that modulus can be
         * optimized into bitwise and.
         */
        int len = (bkts.length >> 1) - 1;
        /*
         * linear probing!
         * note: a & b - 1 where b % 2 == 0 -> a % b
         */
        int probe_idx = key & len;
        do {
            int val = bkts[probe_idx + probe_idx + 1];
            /* did we reach the end of our table? */
            if (val == -1) {
                return -1;
            }
            /* have we found our key? */
            if (bkts[probe_idx + probe_idx] == key) {
                return val;
            }
            /* 
             * linear probing: NEXT!
             * note: step size of 1
             */
            probe_idx = key & probe_idx + 1;
        } while (true);
    }
    what about adding entries?
    Reply With Quote  
     

Page 1 of 3 123 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •