handle negative region IDs

also catches some missed semis
This commit is contained in:
Kistaro Windrider 2025-02-22 19:59:04 -08:00
parent 4117608073
commit 764d1e4892
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -110,14 +110,17 @@ class Knife {
} else { } else {
errors.push(`${loc} is region ${r}, not found in merged`) errors.push(`${loc} is region ${r}, not found in merged`)
} }
if (r < 0) {
return "!";
}
// 0...9 and lowercase // 0...9 and lowercase
if (r < 36) { if (r < 36) {
return r.toString(36) return r.toString(36);
} }
// uppercase // uppercase
r -= 26; r -= 26;
if (r < 36) { if (r < 36) {
return r.toString(36).toUpperCase() return r.toString(36).toUpperCase();
} }
// Greek lowercase // Greek lowercase
r -= 36; r -= 36;
@ -134,12 +137,12 @@ class Knife {
return String.fromCodePoint(r + 0x3a3); return String.fromCodePoint(r + 0x3a3);
} }
// Hebrew // Hebrew
r -= 7 r -= 7;
if (r < 27) { if (r < 27) {
return String.fromCodePoint(r+0x5d0); return String.fromCodePoint(r+0x5d0);
} }
// give up // give up
return "?" return "?";
} }
return "."; // room without region return "."; // room without region
})(); })();