Difference between revisions of "194 Cache Format"
From RuneWiki
Jump to navigationJump to searchBlakeman8192 (talk | contribs) m (Reverted edits by 80.80.161.140 (Talk) to last version by Graham) |
m (→Name hashing) |
||
Line 5: | Line 5: | ||
=== Name hashing === | === Name hashing === | ||
− | Every name in the cache was hashed using the following method which is, incidentally, | + | Every name in the cache was hashed using the following method which is, incidentally, similar to the way player names are converted to longs. |
public static final long gethash(String string) { | public static final long gethash(String string) { |
Revision as of 13:10, 15 August 2009
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, similar to the way player names are converted to longs.
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 and the file was given that name.