(x, y, width, height, sock, display, depth)
| 17 | } |
| 18 | |
| 19 | decodeRect(x, y, width, height, sock, display, depth) { |
| 20 | if (this._tiles === 0) { |
| 21 | this._tilesX = Math.ceil(width / 16); |
| 22 | this._tilesY = Math.ceil(height / 16); |
| 23 | this._totalTiles = this._tilesX * this._tilesY; |
| 24 | this._tiles = this._totalTiles; |
| 25 | } |
| 26 | |
| 27 | while (this._tiles > 0) { |
| 28 | let bytes = 1; |
| 29 | |
| 30 | if (sock.rQwait("HEXTILE", bytes)) { |
| 31 | return false; |
| 32 | } |
| 33 | |
| 34 | let subencoding = sock.rQpeek8(); |
| 35 | if (subencoding > 30) { // Raw |
| 36 | throw new Error("Illegal hextile subencoding (subencoding: " + |
| 37 | subencoding + ")"); |
| 38 | } |
| 39 | |
| 40 | const currTile = this._totalTiles - this._tiles; |
| 41 | const tileX = currTile % this._tilesX; |
| 42 | const tileY = Math.floor(currTile / this._tilesX); |
| 43 | const tx = x + tileX * 16; |
| 44 | const ty = y + tileY * 16; |
| 45 | const tw = Math.min(16, (x + width) - tx); |
| 46 | const th = Math.min(16, (y + height) - ty); |
| 47 | |
| 48 | // Figure out how much we are expecting |
| 49 | if (subencoding & 0x01) { // Raw |
| 50 | bytes += tw * th * 4; |
| 51 | } else { |
| 52 | if (subencoding & 0x02) { // Background |
| 53 | bytes += 4; |
| 54 | } |
| 55 | if (subencoding & 0x04) { // Foreground |
| 56 | bytes += 4; |
| 57 | } |
| 58 | if (subencoding & 0x08) { // AnySubrects |
| 59 | bytes++; // Since we aren't shifting it off |
| 60 | |
| 61 | if (sock.rQwait("HEXTILE", bytes)) { |
| 62 | return false; |
| 63 | } |
| 64 | |
| 65 | let subrects = sock.rQpeekBytes(bytes).at(-1); |
| 66 | if (subencoding & 0x10) { // SubrectsColoured |
| 67 | bytes += subrects * (4 + 2); |
| 68 | } else { |
| 69 | bytes += subrects * 2; |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | if (sock.rQwait("HEXTILE", bytes)) { |
| 75 | return false; |
| 76 | } |
nothing calls this directly
no test coverage detected