mirror of
https://github.com/Terncode/pixel.horse.git
synced 2026-09-24 21:55:52 +02:00
Archive Update 53.1 (#62)
* Normalize BOM and line endings * Archive update 0.53.1
This commit is contained in:
committed by
Eliot Partridge
parent
3599e91bc0
commit
782f8c731c
@@ -14,7 +14,7 @@ import {
|
||||
} from '../client/ponyUtils';
|
||||
import { CM_SIZE } from './constants';
|
||||
|
||||
export const VERSION = 3;
|
||||
export const VERSION = 4;
|
||||
|
||||
interface FieldDefinition<T> {
|
||||
name: keyof PonyInfo;
|
||||
@@ -186,7 +186,7 @@ const COLORS_LENGTH_BITS = 10; // max 1024
|
||||
const BOOLEAN_FIELDS_LENGTH_BITS = 4; // max 15
|
||||
const NUMBER_FIELDS_LENGTH_BITS = 4; // max 15
|
||||
const COLOR_FIELDS_LENGTH_BITS = 4; // max 15
|
||||
const SET_FIELDS_LENGTH_BITS = 5; // max 31
|
||||
const SET_FIELDS_LENGTH_BITS = 6; // max 63
|
||||
const CM_LENGTH_BITS = 5; // max 31
|
||||
const NUMBERS_BITS = 6; // max 63
|
||||
|
||||
@@ -552,6 +552,11 @@ const readNumber = readBits(NUMBERS_BITS);
|
||||
|
||||
export function readPony(read: ReadBits): Precompressed {
|
||||
const version = read(VERSION_BITS);
|
||||
|
||||
if (version > VERSION) {
|
||||
throw new Error('Invalid version');
|
||||
}
|
||||
|
||||
const colors = readFields(read, COLORS_LENGTH_BITS, readColorValue);
|
||||
const colorBits = Math.max(numberToBitCount(colors.length), 1);
|
||||
const readColor = readBits(colorBits);
|
||||
@@ -559,7 +564,7 @@ export function readPony(read: ReadBits): Precompressed {
|
||||
const customOutlines = !!booleanFields[0];
|
||||
const numberFields = readFields(read, NUMBER_FIELDS_LENGTH_BITS, readNumber);
|
||||
const colorFields = readFields(read, COLOR_FIELDS_LENGTH_BITS, readColor);
|
||||
const setFields = readFields(read, SET_FIELDS_LENGTH_BITS, read => readSet(read, colorBits, customOutlines));
|
||||
const setFields = readFields(read, version < 4 ? 5 : SET_FIELDS_LENGTH_BITS, read => readSet(read, colorBits, customOutlines));
|
||||
const cm = readFields(read, CM_LENGTH_BITS, readColor);
|
||||
return { version, colors, booleanFields, numberFields, colorFields, setFields, cm };
|
||||
}
|
||||
|
||||
@@ -2327,7 +2327,9 @@ export const stashEntities = [
|
||||
];
|
||||
|
||||
export const placeableEntities: { type: number; name: string; }[] = [
|
||||
{ type: cushion1.type, name: 'Cushion' },
|
||||
{ type: cushion1.type, name: 'Cushion (red)' },
|
||||
{ type: cushion2.type, name: 'Cushion (blue)' },
|
||||
{ type: cushion3.type, name: 'Cushion (green)' },
|
||||
{ type: barrel.type, name: 'Barrel' },
|
||||
{ type: box.type, name: 'Box' },
|
||||
{ type: boxLanterns.type, name: 'Box of lanterns' },
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
import { fromPairs } from 'lodash';
|
||||
import { matchRomaji, replaceRomaji } from '../client/clientUtils';
|
||||
import { flatten } from './utils';
|
||||
|
||||
const MAX_REPEATS = 16; // needs to be even for emoji
|
||||
|
||||
export const ipRegexText = '(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})';
|
||||
export const ipExceptionRegex = /\d\.\d\.\d\.\d/ui;
|
||||
export const urlExceptionRegex = /^(battle|paint|f(im|an)fiction)\.net$/ui;
|
||||
export const ipExceptionRegex = /\d\.\d\.\d\.\d/i;
|
||||
export const urlExceptionRegex = /^(battle|paint|f(im|an)fiction)\.net$/i;
|
||||
export const urlRegexTexts = [
|
||||
'https?:?//\\S+',
|
||||
'\\bwww\\.[^. ]\\S+',
|
||||
@@ -22,143 +18,3 @@ export function trimRepeatedLetters(test: string): string {
|
||||
return test;
|
||||
}
|
||||
}
|
||||
|
||||
function createCharacterMap(data: string[][]): { [key: string]: string; } {
|
||||
const mappings = data.map(([to, from]) => from.split(/ /g).map(x => [x, to]));
|
||||
return fromPairs(flatten(mappings));
|
||||
}
|
||||
|
||||
const characters = createCharacterMap([
|
||||
[`'`, 'Ъ ъ Ь ь'],
|
||||
['a', 'á ă ắ ặ ằ ẳ ẵ ǎ â ấ ậ ầ ẩ ẫ ä ǟ ȧ ǡ ạ ȁ à ả ȃ ā ą ᶏ ẚ å ǻ ḁ ⱥ ã ɐ ₐ А а @ α'],
|
||||
['A', 'Á Ă Ắ Ặ Ằ Ẳ Ẵ Ǎ Â Ấ Ậ Ầ Ẩ Ẫ Ä Ǟ Ȧ Ǡ Ạ Ȁ À Ả Ȃ Ā Ą Å Ǻ Ḁ Ⱥ Ã Ɐ ᴀ'],
|
||||
['aa', 'ꜳ'],
|
||||
['AA', 'Ꜳ'],
|
||||
['ae', 'æ ǽ ǣ ᴂ'],
|
||||
['AE', 'Æ Ǽ Ǣ ᴁ'],
|
||||
['ao', 'ꜵ'],
|
||||
['AO', 'Ꜵ'],
|
||||
['au', 'ꜷ'],
|
||||
['AU', 'Ꜷ'],
|
||||
['av', 'ꜹ ꜻ'],
|
||||
['AV', 'Ꜹ Ꜻ'],
|
||||
['ay', 'ꜽ'],
|
||||
['AY', 'Ꜽ'],
|
||||
['b', 'ḃ ḅ ɓ ḇ ᵬ ᶀ ƀ ƃ б'],
|
||||
['B', 'Ḃ Ḅ Ɓ Ḇ Ƀ Ƃ ʙ ᴃ Б'],
|
||||
['c', 'ć č ç ḉ ĉ ɕ ċ ƈ ȼ ↄ ꜿ'],
|
||||
['C', 'Ć Č Ç Ḉ Ĉ Ċ Ƈ Ȼ Ꜿ ᴄ'],
|
||||
['ch', 'ч'],
|
||||
['CH', 'Ч'],
|
||||
['d', 'ď ḑ ḓ ȡ ḋ ḍ ɗ ᶑ ḏ ᵭ ᶁ đ ɖ ƌ ꝺ д'],
|
||||
['D', 'Ď Ḑ Ḓ Ḋ Ḍ Ɗ Ḏ Dz Dž Đ Ƌ Ꝺ ᴅ Д'],
|
||||
['dz', 'dz dž'],
|
||||
['DZ', 'DZ DŽ'],
|
||||
['e', 'é ĕ ě ȩ ḝ ê ế ệ ề ể ễ ḙ ë ė ẹ ȅ è ẻ ȇ ē ḗ ḕ ⱸ ę ᶒ ɇ ẽ ḛ ɛ ᶓ ɘ ǝ ₑ е э ε'],
|
||||
['E', 'É Ĕ Ě Ȩ Ḝ Ê Ế Ệ Ề Ể Ễ Ḙ Ë Ė Ẹ Ȅ È Ẻ Ȇ Ē Ḗ Ḕ Ę Ɇ Ẽ Ḛ Ɛ Ǝ ᴇ ⱻ Е Э'],
|
||||
['et', 'ꝫ'],
|
||||
['ET', 'Ꝫ'],
|
||||
['f', 'ḟ ƒ ᵮ ᶂ ꝼ ф'],
|
||||
['F', 'Ḟ Ƒ Ꝼ ꜰ Ф'],
|
||||
['ff', 'ff'],
|
||||
['ffi', 'ffi'],
|
||||
['ffl', 'ffl'],
|
||||
['fi', 'fi'],
|
||||
['fl', 'fl'],
|
||||
['g', 'ǵ ğ ǧ ģ ĝ ġ ɠ ḡ ᶃ ǥ ᵹ ɡ ᵷ г'],
|
||||
['G', 'Ǵ Ğ Ǧ Ģ Ĝ Ġ Ɠ Ḡ Ǥ Ᵹ ɢ ʛ Г'],
|
||||
['h', 'ḫ ȟ ḩ ĥ ⱨ ḧ ḣ ḥ ɦ ẖ ħ ɥ ʮ ʯ х'],
|
||||
['H', 'Ḫ Ȟ Ḩ Ĥ Ⱨ Ḧ Ḣ Ḥ Ħ ʜ Х'],
|
||||
['hv', 'ƕ'],
|
||||
['i', 'ı í ĭ ǐ î ï ḯ ị ȉ ì ỉ ȋ ī į ᶖ ɨ ĩ ḭ ᴉ ᵢ й ы и ι'],
|
||||
['I', 'Í Ĭ Ǐ Î Ï Ḯ İ Ị Ȉ Ì Ỉ Ȋ Ī Į Ɨ Ĩ Ḭ ɪ Й Ы И'],
|
||||
['ij', 'ij'],
|
||||
['IJ', 'IJ'],
|
||||
['is', 'ꝭ'],
|
||||
['IS', 'Ꝭ'],
|
||||
['j', 'ȷ ɟ ʄ ǰ ĵ ʝ ɉ ⱼ'],
|
||||
['J', 'Ĵ Ɉ ᴊ'],
|
||||
['k', 'ḱ ǩ ķ ⱪ ꝃ ḳ ƙ ḵ ᶄ ꝁ ꝅ ʞ к'],
|
||||
['K', 'Ḱ Ǩ Ķ Ⱪ Ꝃ Ḳ Ƙ Ḵ Ꝁ Ꝅ ᴋ К'],
|
||||
['l', 'ĺ ƚ ɬ ľ ļ ḽ ȴ ḷ ḹ ⱡ ꝉ ḻ ŀ ɫ ᶅ ɭ ł ꞁ л'],
|
||||
['L', 'Ĺ Ƚ Ľ Ļ Ḽ Ḷ Ḹ Ⱡ Ꝉ Ḻ Ŀ Ɫ Lj Ł Ꞁ ʟ ᴌ Л'],
|
||||
['lj', 'lj'],
|
||||
['LJ', 'LJ'],
|
||||
['m', 'ḿ ṁ ṃ ɱ ᵯ ᶆ ɯ ɰ м'],
|
||||
['M', 'Ḿ Ṁ Ṃ Ɱ Ɯ ᴍ М'],
|
||||
['n', 'ń ň ņ ṋ ȵ ṅ ṇ ǹ ɲ ṉ ƞ ᵰ ᶇ ɳ ñ н η'],
|
||||
['N', 'Ń Ň Ņ Ṋ Ṅ Ṇ Ǹ Ɲ Ṉ Ƞ Nj Ñ ɴ ᴎ Н'],
|
||||
['nj', 'nj'],
|
||||
['NJ', 'NJ'],
|
||||
['o', 'ɵ ó ŏ ǒ ô ố ộ ồ ổ ỗ ö ȫ ȯ ȱ ọ ő ȍ ò ỏ ơ ớ ợ ờ ở ỡ ȏ ꝋ ꝍ ⱺ ō ṓ ṑ ǫ ǭ ø ǿ õ ṍ ṏ ȭ ɔ ᶗ ᴑ ᴓ ₒ о'],
|
||||
['O', 'Ó Ŏ Ǒ Ô Ố Ộ Ồ Ổ Ỗ Ö Ȫ Ȯ Ȱ Ọ Ő Ȍ Ò Ỏ Ơ Ớ Ợ Ờ Ở Ỡ Ȏ Ꝋ Ꝍ Ō Ṓ Ṑ Ɵ Ǫ Ǭ Ø Ǿ Õ Ṍ Ṏ Ȭ Ɔ ᴏ ᴐ О'],
|
||||
['oe', 'ᴔ œ'],
|
||||
['OE', 'Œ ɶ'],
|
||||
['oi', 'ƣ'],
|
||||
['OI', 'Ƣ'],
|
||||
['oo', 'ꝏ'],
|
||||
['OO', 'Ꝏ'],
|
||||
['ou', 'ȣ'],
|
||||
['OU', 'Ȣ ᴕ'],
|
||||
['p', 'ṕ ṗ ꝓ ƥ ᵱ ᶈ ꝕ ᵽ ꝑ п'],
|
||||
['P', 'Ṕ Ṗ Ꝓ Ƥ Ꝕ Ᵽ Ꝑ ᴘ П'],
|
||||
['q', 'ꝙ ʠ ɋ ꝗ'],
|
||||
['Q', 'Ꝙ Ꝗ'],
|
||||
['r', 'ꞃ ŕ ř ŗ ṙ ṛ ṝ ȑ ɾ ᵳ ȓ ṟ ɼ ᵲ ᶉ ɍ ɽ ɿ ɹ ɻ ɺ ⱹ ᵣ р'],
|
||||
['R', 'Ꞃ Ŕ Ř Ŗ Ṙ Ṛ Ṝ Ȑ Ȓ Ṟ Ɍ Ɽ ʁ ʀ ᴙ ᴚ Р ®'],
|
||||
['s', 'ꞅ ſ ẜ ẛ ẝ ś ṥ š ṧ ş ŝ ș ṡ ṣ ṩ ʂ ᵴ ᶊ ȿ с'],
|
||||
['S', 'Ꞅ Ś Ṥ Š Ṧ Ş Ŝ Ș Ṡ Ṣ Ṩ ꜱ С $'],
|
||||
['sch', 'щ'],
|
||||
['SCH', 'Щ'],
|
||||
['sh', 'ш'],
|
||||
['SH', 'Ш'],
|
||||
['ss', 'ß'],
|
||||
['st', 'st'],
|
||||
['t', 'ꞇ ť ţ ṱ ț ȶ ẗ ⱦ ṫ ṭ ƭ ṯ ᵵ ƫ ʈ ŧ ʇ т'],
|
||||
['T', 'Ꞇ Ť Ţ Ṱ Ț Ⱦ Ṫ Ṭ Ƭ Ṯ Ʈ Ŧ ᴛ Т'],
|
||||
['th', 'ᵺ'],
|
||||
['ts', 'ц'],
|
||||
['TS', 'Ц'],
|
||||
['tz', 'ꜩ'],
|
||||
['TZ', 'Ꜩ'],
|
||||
['u', 'ᴝ ú ŭ ǔ û ṷ ü ǘ ǚ ǜ ǖ ṳ ụ ű ȕ ù ủ ư ứ ự ừ ử ữ ȗ ū ṻ ų ᶙ ů ũ ṹ ṵ ᵤ у'],
|
||||
['U', 'Ú Ŭ Ǔ Û Ṷ Ü Ǘ Ǚ Ǜ Ǖ Ṳ Ụ Ű Ȕ Ù Ủ Ư Ứ Ự Ừ Ử Ữ Ȗ Ū Ṻ Ų Ů Ũ Ṹ Ṵ ᴜ У'],
|
||||
['ue', 'ᵫ'],
|
||||
['um', 'ꝸ'],
|
||||
['v', 'ʌ ⱴ ꝟ ṿ ʋ ᶌ ⱱ ṽ ᵥ в'],
|
||||
['V', 'Ʌ Ꝟ Ṿ Ʋ Ṽ ᴠ В'],
|
||||
['vy', 'ꝡ'],
|
||||
['VY', 'Ꝡ'],
|
||||
['w', 'ʍ ẃ ŵ ẅ ẇ ẉ ẁ ⱳ ẘ'],
|
||||
['W', 'Ẃ Ŵ Ẅ Ẇ Ẉ Ẁ Ⱳ ᴡ'],
|
||||
['x', 'ẍ ẋ ᶍ ₓ'],
|
||||
['X', 'Ẍ Ẋ'],
|
||||
['y', 'ʎ ý ŷ ÿ ẏ ỵ ỳ ƴ ỷ ỿ ȳ ẙ ɏ ỹ'],
|
||||
['Y', 'Ý Ŷ Ÿ Ẏ Ỵ Ỳ Ƴ Ỷ Ỿ Ȳ Ɏ Ỹ ʏ'],
|
||||
['ya', 'я'],
|
||||
['Ya', 'Я'],
|
||||
['yo', 'ё'],
|
||||
['YO', 'Ё'],
|
||||
['yu', 'ю'],
|
||||
['YU', 'Ю'],
|
||||
['z', 'ź ž ẑ ʑ ⱬ ż ẓ ȥ ẕ ᵶ ᶎ ʐ ƶ ɀ з'],
|
||||
['Z', 'Ź Ž Ẑ Ⱬ Ż Ẓ Ȥ Ẕ Ƶ ᴢ З'],
|
||||
['zh', 'ж'],
|
||||
['ZH', 'Ж'],
|
||||
]);
|
||||
|
||||
const nonAscii = /[^A-Za-z0-9]/g;
|
||||
|
||||
export function latinize(text: string): string {
|
||||
return text
|
||||
.replace(matchRomaji, replaceRomaji)
|
||||
.replace(nonAscii, x => characters[x] || x);
|
||||
}
|
||||
|
||||
export function latinize2(name: string): string {
|
||||
return latinize(name
|
||||
.replace(/[ǫ]/ui, 'q')
|
||||
.replace(/[с]/ui, 'c')
|
||||
.replace(/[н]|\|-\|/ui, 'h')
|
||||
.replace(/[лпий]/ui, 'n'));
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ export function isPaletteSpriteBatch(batch: SpriteBatch | PaletteSpriteBatch): b
|
||||
|
||||
export interface ServerFeatureFlags {
|
||||
test?: boolean; // test server
|
||||
objects?: boolean; // editor
|
||||
editor?: boolean; // editor
|
||||
// more flags here ...
|
||||
}
|
||||
|
||||
|
||||
+27
-18
@@ -1475,15 +1475,24 @@ export function isAscii(text: string) {
|
||||
const unicode = createBadWords(false);
|
||||
const ascii = createBadWords(true);
|
||||
|
||||
const replaceRegex = (values: string[]) => new RegExp(`\\b(?:${values.join('|')})\\b`, 'ugi');
|
||||
const replaceRegexRU = (values: string[]) => new RegExp(`${wordStartRU}(?:${values.join('|')})${wordEndRU}`, 'ugi');
|
||||
const replaceRegexOther = (values: string[]) => new RegExp(`(?:${values.join('|')})`, 'ugi');
|
||||
const replaceRegexSpecific = (values: string[]) => new RegExp(`(?:${values.join('|')})`, 'ug');
|
||||
function tryRegex(value: string, flags: string) {
|
||||
try {
|
||||
return new RegExp(value, flags);
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
return new RegExp(/(?!.*)/);
|
||||
}
|
||||
}
|
||||
|
||||
const testRegex = (values: string[]) => new RegExp(`\\b(?:${values.join('|')})\\b`, 'ui');
|
||||
const testRegexRU = (values: string[]) => new RegExp(`${wordStartRU}(?:${values.join('|')})${wordEndRU}`, 'ui');
|
||||
const testRegexOther = (values: string[]) => new RegExp(`(?:${values.join('|')})`, 'ui');
|
||||
const testRegexSpecific = (values: string[]) => new RegExp(`(?:${values.join('|')})`, 'u');
|
||||
const replaceRegex = (values: string[]) => tryRegex(`\\b(?:${values.join('|')})\\b`, 'ugi');
|
||||
const replaceRegexRU = (values: string[]) => tryRegex(`${wordStartRU}(?:${values.join('|')})${wordEndRU}`, 'ugi');
|
||||
const replaceRegexOther = (values: string[]) => tryRegex(`(?:${values.join('|')})`, 'ugi');
|
||||
const replaceRegexSpecific = (values: string[]) => tryRegex(`(?:${values.join('|')})`, 'ug');
|
||||
|
||||
const testRegex = (values: string[]) => tryRegex(`\\b(?:${values.join('|')})\\b`, 'ui');
|
||||
const testRegexRU = (values: string[]) => tryRegex(`${wordStartRU}(?:${values.join('|')})${wordEndRU}`, 'ui');
|
||||
const testRegexOther = (values: string[]) => tryRegex(`(?:${values.join('|')})`, 'ui');
|
||||
const testRegexSpecific = (values: string[]) => tryRegex(`(?:${values.join('|')})`, 'u');
|
||||
|
||||
const regexReplace = replaceRegex(unicode.all);
|
||||
const regexReplaceRU = replaceRegexRU(unicode.foreign);
|
||||
@@ -1507,8 +1516,8 @@ const regexTestSpecificFast = testRegexSpecific(ascii.specific);
|
||||
|
||||
const regexTestFuck = testRegex(unicode.fuck);
|
||||
|
||||
const regexReplaceRUSingle = new RegExp(`${unicode.foreign.join('|')}`, 'ugi');
|
||||
const regexReplacePartial = new RegExp(`${[
|
||||
const regexReplaceRUSingle = tryRegex(`${unicode.foreign.join('|')}`, 'ugi');
|
||||
const regexReplacePartial = tryRegex(`${[
|
||||
...unicode.all, ...unicode.foreign, ...unicode.other, ...unicode.specific
|
||||
].join('|')}`, 'ugi');
|
||||
|
||||
@@ -1579,17 +1588,17 @@ export function filterBadWordsPartial(text: string, replacer = defaultReplacer):
|
||||
}
|
||||
|
||||
export function findMatch(text: string): string | undefined {
|
||||
return unicode.all.find(x => (new RegExp(`\\b(?:${x})\\b`, 'ui')).test(text))
|
||||
|| unicode.foreign.find(x => (new RegExp(`${wordStartRU}(?:${x})${wordEndRU}`, 'ui')).test(text))
|
||||
|| unicode.other.find(x => (new RegExp(`${x}`, 'u')).test(text))
|
||||
|| unicode.specific.find(x => (new RegExp(`${x}`, 'u')).test(text));
|
||||
return unicode.all.find(x => (tryRegex(`\\b(?:${x})\\b`, 'ui')).test(text))
|
||||
|| unicode.foreign.find(x => (tryRegex(`${wordStartRU}(?:${x})${wordEndRU}`, 'ui')).test(text))
|
||||
|| unicode.other.find(x => (tryRegex(`${x}`, 'u')).test(text))
|
||||
|| unicode.specific.find(x => (tryRegex(`${x}`, 'u')).test(text));
|
||||
}
|
||||
|
||||
export function createMatchEntries() {
|
||||
return [
|
||||
...unicode.all.map(line => ({ line, regex: new RegExp(`\\b(?:${line})\\b`, 'ui') })),
|
||||
...unicode.foreign.map(line => ({ line, regex: new RegExp(`${wordStartRU}(?:${line})${wordEndRU}`, 'ui') })),
|
||||
...unicode.other.map(line => ({ line, regex: new RegExp(line, 'ui') })),
|
||||
...unicode.specific.map(line => ({ line, regex: new RegExp(line, 'u') })),
|
||||
...unicode.all.map(line => ({ line, regex: tryRegex(`\\b(?:${line})\\b`, 'ui') })),
|
||||
...unicode.foreign.map(line => ({ line, regex: tryRegex(`${wordStartRU}(?:${line})${wordEndRU}`, 'ui') })),
|
||||
...unicode.other.map(line => ({ line, regex: tryRegex(line, 'ui') })),
|
||||
...unicode.specific.map(line => ({ line, regex: tryRegex(line, 'u') })),
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user