Skip to content

Commit

Permalink
Fix localized quest messages not restored on load
Browse files Browse the repository at this point in the history
Localized quest messages were not reimported when loading a game. This did not matter if quest was recently compiled as localizations were already memory resident. But once game was closed and restarted, localizations are lost. These are supposed to be available for entire lifetime of quest.
Added a step to restore localized quest messages on load.
  • Loading branch information
Interkarma committed Oct 18, 2023
1 parent 01fbb72 commit b896674
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
Expand Up @@ -2274,6 +2274,7 @@ public static string Execute(params string[] args)
if (quest != null)
{
QuestMachine.Instance.StartQuest(quest);
QuestMachine.Instance.RestoreLocalizedQuestMessages(quest.QuestName);
return "Started quest '" + quest.DisplayName + "'";
}
else
Expand Down
3 changes: 3 additions & 0 deletions Assets/Scripts/Game/Questing/Quest.cs
Expand Up @@ -1007,6 +1007,9 @@ public void RestoreSaveData(QuestSaveData_v1 data)
messages.Add(message.ID, message);
}

// Restore localized messages
QuestMachine.Instance.RestoreLocalizedQuestMessages(questName);

// Restore resources
resources.Clear();
foreach(QuestResource.ResourceSaveData_v1 resourceData in data.resources)
Expand Down
9 changes: 9 additions & 0 deletions Assets/Scripts/Game/Questing/QuestMachine.cs
Expand Up @@ -686,6 +686,15 @@ public Quest ParseQuest(string questName, string[] questSource, int factionId =
}
}

/// <summary>
/// Localized quest messages need to be restored when game is loaded.
/// </summary>
/// <param name="questName">Name of quest to restore localized messages.</param>
public bool RestoreLocalizedQuestMessages(string questName)
{
return ParseLocalizedQuestText(questName);
}

/// <summary>
/// Parse and start a quest from quest name.
/// </summary>
Expand Down

0 comments on commit b896674

Please sign in to comment.