Skip to content

Commit

Permalink
fix: fix crash loading saves with value-less loc variables
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelMakesGames committed Aug 20, 2024
1 parent 24cd624 commit ee3eeb2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/renderer/src/lib/GameState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface LocalizedText {
key: string;
variables?: {
key: string;
value: LocalizedText;
value?: LocalizedText;
}[];
}
const localizedTextSchemaNoDefault: z.ZodType<LocalizedText> = z.object({
Expand All @@ -34,7 +34,7 @@ const localizedTextSchemaNoDefault: z.ZodType<LocalizedText> = z.object({
.array(
z.object({
key: z.coerce.string(),
value: z.lazy(() => localizedTextSchemaNoDefault),
value: z.lazy(() => localizedTextSchemaNoDefault.optional()),
}),
)
.optional(),
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/lib/map/data/locUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function localizeTextSync(
} else if (text.key === '%ADJ%') {
try {
const var0 = text.variables?.[0];
if (!var0 || !var0.value.variables) throw new Error();
if (!var0 || !var0.value?.variables) throw new Error();
const adj = loc[var0.value.key] ?? var0.value.key;
if (adj.includes('$1$')) {
return localizeTextSync(var0.value, loc);
Expand Down

0 comments on commit ee3eeb2

Please sign in to comment.