diff options
-rw-r--r-- | socket.js | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -2,6 +2,8 @@ const ws = require('ws') const EventEmitter = require('events'); +let mod = (div, end) => ( ( (div % end) + end ) % end ) // Makes it such that (-2) % 3 = 1 instead of -2. + class retryws extends EventEmitter{ // a wrapper on ws that retries on failure constructor(addr) { super(); @@ -63,7 +65,13 @@ class Socket extends retryws { for (var i=0; i<chars.length; i++){ let char = chars[i] let coord = char[0]; - chars[i] = [Math.floor(coord[0]/8),Math.floor(coord[1]/16),(coord[0] % 8),(coord[1] % 16),char[1]]; + chars[i] = [ + Math.floor(coord[0]/8), + Math.floor(coord[1]/16), + mod(coord[0], 8), + mod(coord[1], 16), + char[1] + ]; chars[i].splice(4,0,0); chars[i].push(i); } |