Muchaszewski / DSP_TranslationMod

Mod for Dyson Sphere Program that enables language translations
Other
14 stars 3 forks source link

Error on startup #2

Closed Muchaszewski closed 3 years ago

Muchaszewski commented 3 years ago

Once every 10 times this bug arises and the game does not load anymore...

[Error : Unity Log] NullReferenceException: Object reference not set to an instance of an object Stack trace: TranslationCommon.Translation.TranslationManager.LoadCurrentLanguage () TranslationCommon.Translation.TranslationManager.get_Langauges () TranslationCommon.Translation.TranslationManager.LoadCurrentLanguage () DSPTranslationPlugin.GameHarmony.GlobalObject_Initialize_Harmony.Prefix () GlobalObject.Initialize ()

Couldn't catch it in the debugger. Leaving issue because someone might have reproduction steps for this issue, that would help! Thanks :)

limoka commented 3 years ago

I think i know the cause. I added this small printout in TranslationManager.LoadCurrentLanguage function:

if (!string.IsNullOrEmpty(SelectedLanguage))
{
    var selectedContainer = Languages.FirstOrDefault(container =>
        container.Settings.LanguageDisplayName == SelectedLanguage);
    CurrentLanguage = selectedContainer;
    Localization.language = Language.enUS;
    if (Localization.OnLanguageChange == null)
    {
        ConsoleLogger.LogDebug("Found the null pointer!");
    }
    Localization.OnLanguageChange(Language.enUS);
}

And this in console with this code:

[Message:   BepInEx] Chainloader startup complete
[Debug  :ConsoleLogger] Found the null pointer!
[Error  : Unity Log] NullReferenceException: Object reference not set to an instance of an object
Stack trace:
TranslationCommon.Translation.TranslationManager.LoadCurrentLanguage () <IL 0x0015b, 0x00cac>
TranslationCommon.Translation.TranslationManager.get_Languages () <IL 0x00021, 0x00192>
TranslationCommon.Translation.TranslationManager.LoadCurrentLanguage () <IL 0x00018, 0x001a4>
DSPTranslationPlugin.GameHarmony.GlobalObject_Initialize_Harmony.Prefix () <IL 0x00021, 0x00172>
(wrapper dynamic-method) GlobalObject.DMD<GlobalObject..Initialize> () <IL 0x00002, 0x0006d>

[Error  : Unity Log] System.NullReferenceException: Object reference not set to an instance of an object
  at UIOptionWindow._OnCreate () [0x00000] in <filename unknown>:0
  at ManualBehaviour._Create () [0x00000] in <filename unknown>:0
Muchaszewski commented 3 years ago

Good catch! Thank you.

Case closed!