mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-25 05:54:36 +00:00
fixed
This commit is contained in:
@@ -9,67 +9,67 @@
|
||||
},
|
||||
"pattern": {
|
||||
"stripes_v": {
|
||||
"pattern": "AQACAAIACAU=",
|
||||
"pattern": "ARAIBQ==",
|
||||
"role_group": ["all"]
|
||||
},
|
||||
"stripes_h": {
|
||||
"pattern": "AQACAAIACAM=",
|
||||
"pattern": "ARAIAw==",
|
||||
"role_group": ["all"]
|
||||
},
|
||||
"checkerboard": {
|
||||
"pattern": "AQACAAIACAk=",
|
||||
"pattern": "ARAICQ==",
|
||||
"role_group": ["all"]
|
||||
},
|
||||
"diagonal": {
|
||||
"pattern": "AQAQABAAAQEAAgAEAAgAEAAgAEAAgAAAAQACAAQACAAQACAAQACA",
|
||||
"pattern": "AYFAAQACAAQACAAQACAAQACAAAABAAIABAAIABAAIABAAIA=",
|
||||
"role_group": ["donor", "staff"]
|
||||
},
|
||||
"cross": {
|
||||
"pattern": "AQAQABAAAQGAAkAEIAgQEAggBEACgAGAAUACIAQQCAgQBCACQAGA",
|
||||
"pattern": "AYFAAYACQAQgCBAQCCAEQAKAAYABQAIgBBAICBAEIAJAAYA=",
|
||||
"role_group": ["donor", "staff"]
|
||||
},
|
||||
"mini_cross": {
|
||||
"pattern": "AQAQAAgAAQPADDAwDMADwAMwDAwwA8A=",
|
||||
"pattern": "AYEgA8AMMDAMwAPAAzAMDDADwA==",
|
||||
"role_group": ["donor", "staff"]
|
||||
},
|
||||
"horizontal_stripes": {
|
||||
"pattern": "AQAQABAAAf//AAAAAAAAAAAAAAAAAAD//wAAAAAAAAAAAAAAAAAA",
|
||||
"pattern": "AYFA//8AAAAAAAAAAAAAAAAAAP//AAAAAAAAAAAAAAAAAAA=",
|
||||
"role_group": ["donor", "staff"]
|
||||
},
|
||||
"sparse_dots": {
|
||||
"pattern": "AQAQABAAAQEBAAAAAAAAAAAAAAAAAAABAQAAAAAAAAAAAAAAAAAA",
|
||||
"pattern": "AYFAAQEAAAAAAAAAAAAAAAAAAAEBAAAAAAAAAAAAAAAAAAA=",
|
||||
"role_group": ["donor", "staff"]
|
||||
},
|
||||
"evan": {
|
||||
"pattern": "AQAYAAcABAAAAJ7ESIIkWY7kaQIjSR4jSQAAAA==",
|
||||
"pattern": "AcQcAAAAnsRIgiRZjuRpAiNJHiNJAAAA",
|
||||
"role_group": ["staff"]
|
||||
},
|
||||
"diagonal_stripe": {
|
||||
"pattern": "AQAQAAgAAQGAAkAEIAgQEAggBEACgAE=",
|
||||
"pattern": "AYEgAYACQAQgCBAQCCAEQAKAAQ==",
|
||||
"role_group": ["donor", "staff"]
|
||||
},
|
||||
"mountain_ridge": {
|
||||
"pattern": "AQAQAAgAAQAAGBg8PH5+//9+fjw8GBg=",
|
||||
"pattern": "AYEgAAAYGDw8fn7//35+PDwYGA==",
|
||||
"role_group": ["donor", "staff"]
|
||||
},
|
||||
"scattered_dots": {
|
||||
"pattern": "AQAQAAgAAQAAAiAAAAAAAAAAAAgQAAA=",
|
||||
"pattern": "AYEgAAACIAAAAAAAAAAACBAAAA==",
|
||||
"role_group": ["donor", "staff"]
|
||||
},
|
||||
"circuit_board": {
|
||||
"pattern": "AQAQAAgAAcPDw8MMDAwMMAwwDMPDw8M=",
|
||||
"pattern": "AYEgw8PDwwwMDAwwDDAMw8PDww==",
|
||||
"role_group": ["donor", "staff"]
|
||||
},
|
||||
"vertical_bars": {
|
||||
"pattern": "AQAQAAgAAUmSSZJJkkmSSZJJkkmSSZI=",
|
||||
"pattern": "AYEgSZJJkkmSSZJJkkmSSZJJkg==",
|
||||
"role_group": ["donor", "staff"]
|
||||
},
|
||||
".w.": {
|
||||
"pattern": "AQAQAAgAAQAAAAAAAAJAgkFEIi50Fmg=",
|
||||
"pattern": "AYEgAAAAAAAAAkCCQUQiLnQWaA==",
|
||||
"role_group": ["donor", "staff"]
|
||||
},
|
||||
"openfront": {
|
||||
"pattern": "AQBCAAoABAAAAAAAAAAAAAAAAAAAAACAw/GJ8Hk4og+RSGBCIBKZCEQigQqBSKQiEHk8MjwekYxAJBCIEChEIgKRQCBCIBGJCDgCnwiBiCMiAAAAAAAAAAAA",
|
||||
"pattern": "ARQqAAAAAAAAAAAAAAAAAAAAAIDD8YnweTiiD5FIYEIgEpkIRCKBCoFIpCIQeTwyPB6RjEAkEIgQKEQiApFAIEIgEYkIOAKfCIGIIyIAAAAAAAAAAAA=",
|
||||
"role_group": ["staff"]
|
||||
}
|
||||
}
|
||||
|
||||
+22
-8
@@ -26,7 +26,7 @@ export class PatternDecoder {
|
||||
constructor(base64: string) {
|
||||
const bytes = base64url.decode(base64);
|
||||
|
||||
if (bytes.length < 7) {
|
||||
if (bytes.length < 3) {
|
||||
throw new Error(
|
||||
"Pattern data is too short to contain required metadata.",
|
||||
);
|
||||
@@ -37,14 +37,28 @@ export class PatternDecoder {
|
||||
throw new Error("The pattern versions are different.");
|
||||
}
|
||||
|
||||
this.tileWidth = (bytes[1] << 8) | bytes[2];
|
||||
this.tileHeight = (bytes[3] << 8) | bytes[4];
|
||||
this.scale = (bytes[5] << 8) | bytes[6];
|
||||
const shift = Math.log2(this.scale);
|
||||
if (!Number.isInteger(shift)) {
|
||||
throw new Error("Scale must be a power of 2.");
|
||||
const packed = (bytes[2] << 8) | bytes[1];
|
||||
const scale = packed & 0x7;
|
||||
const width = (packed >> 3) & 0x7f;
|
||||
const height = (packed >> 10) & 0x3f;
|
||||
|
||||
if (
|
||||
scale < 0 ||
|
||||
scale > 7 ||
|
||||
width < 1 ||
|
||||
width > 127 ||
|
||||
height < 1 ||
|
||||
height > 63
|
||||
) {
|
||||
throw new Error(
|
||||
"Scale must be 1–128, width must be 1–127, and height must be 1–63.",
|
||||
);
|
||||
}
|
||||
this.dataStart = 7;
|
||||
|
||||
this.scale = 1 << scale;
|
||||
this.tileWidth = width;
|
||||
this.tileHeight = height;
|
||||
this.dataStart = 3;
|
||||
this.bytes = bytes;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user