194 Cache Format

From RuneWiki
Revision as of 08:37, 13 August 2009 by 82.69.13.77 (talk) (New page: == General Information == The 194 (RuneScape 2 beta) client worked with a very simple cache format. Each file in the cache was a file on the operating system. === Name hashing === Every...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

General Information

The 194 (RuneScape 2 beta) client worked with a very simple cache format. Each file in the cache was a file on the operating system.

Name hashing

Every name in the cache was hashed using the following method which is, incidentally, the same way player names are hashed.

public static final long gethash(String string) {
    string = string.trim();
    long l = 0L;
    for (int i = 0; i < string.length() && i < 12; i++) {
        char c = string.charAt(i);
        l *= 37L;
        if (c >= 'A' && c <= 'Z')
            l += (long) ('\001' + c - 'A');
        else if (c >= 'a' && c <= 'z')
            l += (long) ('\001' + c - 'a');
        else if (c >= '0' && c <= '9')
            l += (long) ('\033' + c - '0');
    }
    return l;
}

The resulting long was converted to a string then the file was given that name.