aboutsummaryrefslogtreecommitdiff
path: root/webAO
diff options
context:
space:
mode:
authoroldmud0 <oldmud0@users.noreply.github.com>2018-05-22 22:30:11 -0500
committeroldmud0 <oldmud0@users.noreply.github.com>2018-05-22 22:30:11 -0500
commite600f7a355a6b26032a3a693276c466477f72924 (patch)
treecf6fdf3a9f57ee7430c1354074ce5bf22630274a /webAO
parent78f8f96b97dffae06bdde1c52bd2d2942a622aa9 (diff)
Use Java hash of user agent as HDID
(sD's idea, not mine!)
Diffstat (limited to 'webAO')
-rw-r--r--webAO/client.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/webAO/client.js b/webAO/client.js
index 44a130c..8dcb929 100644
--- a/webAO/client.js
+++ b/webAO/client.js
@@ -141,7 +141,7 @@ class Client {
* to the server.
*/
joinServer() {
- this.serv.send(`HI#${navigator.userAgent}#%`);
+ this.serv.send(`HI#${navigator.userAgent.hashCode()}#%`);
this.serv.send("ID#webAO#2.4.5#%");
this.CHECKupdater = setInterval(() => this.sendCheck, 5000);
}
@@ -1029,6 +1029,18 @@ if (typeof(String.prototype.trim) === "undefined")
};
}
+// Used for HDID calculation.
+String.prototype.hashCode = function() {
+ var hash = 0, i, chr;
+ if (this.length === 0) return hash;
+ for (i = 0; i < this.length; i++) {
+ chr = this.charCodeAt(i);
+ hash = ((hash << 5) - hash) + chr;
+ hash |= 0; // Convert to 32bit integer
+ }
+ return hash;
+};
+
//
// Client code