diff --git a/CHANGELOG.md b/CHANGELOG.md index bb57078..4521e8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines. +## [0.12.3](https://github.com/MichaelMakesGames/stellarmaps/compare/stellarmaps-v0.12.2...stellarmaps-v0.12.3) (2024-11-30) + +### Bug Fixes + +- gracefully handle megastructures missing `type` ([2ef039c](https://github.com/MichaelMakesGames/stellarmaps/commit/2ef039cfd0223358f0ec8506c17c0a1415dd37cd)) +- handle color and icon codes in player names ([289ffc8](https://github.com/MichaelMakesGames/stellarmaps/commit/289ffc8f9c5a5dba2070001979bfe560743118be)) + ## [0.12.2](https://github.com/MichaelMakesGames/stellarmaps/compare/stellarmaps-v0.12.1...stellarmaps-v0.12.2) (2024-09-18) ### Bug Fixes diff --git a/src/renderer/src/lib/GameState.ts b/src/renderer/src/lib/GameState.ts index 5b2ea95..9670fe5 100644 --- a/src/renderer/src/lib/GameState.ts +++ b/src/renderer/src/lib/GameState.ts @@ -130,7 +130,7 @@ const bypassSchema = z.object({ export type Bypass = WithId>; const megastructureSchema = z.object({ - type: z.string(), + type: z.string().optional(), }); /** diff --git a/src/renderer/src/lib/map/data/locUtils.ts b/src/renderer/src/lib/map/data/locUtils.ts index 8cbf9a7..32c327e 100644 --- a/src/renderer/src/lib/map/data/locUtils.ts +++ b/src/renderer/src/lib/map/data/locUtils.ts @@ -100,7 +100,7 @@ export function localizeTextSync( } } let value = loc[text.key]; - if (value == null) return removeColorCodes(text.key); + if (value == null) return removeColorAndIconCodes(text.key); if (text.variables) { text.variables.forEach((variable) => { const localizedVariable = localizeTextSync(variable.value, loc); @@ -110,9 +110,9 @@ export function localizeTextSync( .replace(`<${variable.key}>`, localizedVariable); }); } - return removeColorCodes(value); + return removeColorAndIconCodes(value); } -function removeColorCodes(text: string): string { - return text.replace(/[\u0011§]./g, ''); // eslint-disable-line no-control-regex +export function removeColorAndIconCodes(text: string): string { + return text.replace(/[\u0011§].?/g, '').replace(/\u0013\w*/g, ''); // eslint-disable-line no-control-regex } diff --git a/src/renderer/src/lib/map/data/processLabels.ts b/src/renderer/src/lib/map/data/processLabels.ts index c1d2da0..97bce86 100644 --- a/src/renderer/src/lib/map/data/processLabels.ts +++ b/src/renderer/src/lib/map/data/processLabels.ts @@ -3,6 +3,7 @@ import polylabel from 'polylabel'; import type { GameState } from '../../GameState'; import type { MapSettings } from '../../settings'; +import { removeColorAndIconCodes } from './locUtils'; import type processBorders from './processBorders'; import type processSystemOwnership from './processSystemOwnership'; import type processTerraIncognita from './processTerraIncognita'; @@ -61,7 +62,9 @@ export default function processLabels( ); const labels = idGeojsonPairs.map(([countryId, geojson]) => { const countryName = countryNames[countryId] ?? ''; - const playerName = gameState.player.find((player) => player.country === countryId)?.name ?? ''; + const playerName = removeColorAndIconCodes( + gameState.player.find((player) => player.country === countryId)?.name ?? '', + ); let primaryName = ''; let secondaryName = ''; switch (settings.countryNamesType) {