TRSasasusu / TranslationForTheOutsider

Universal translation for The Outsider; EN -> JA, pt-BR, zh-CN, RU, FR, DE, IT (making others are welcoming!) And patches to solve some issues of The Outsider
https://outerwildsmods.com/mods/translationandpatchesfortheoutsider/
MIT License
5 stars 7 forks source link

The shiplog is bugged, only a title: PLANET NAME is appeared #20

Closed TRSasasusu closed 1 year ago

TRSasasusu commented 1 year ago

Sometimes, in some environments, the shiplog is bugged, only a title: PLANET NAME is appeared.

image

The error log is below:

ArgumentException: An item with the same key has already been added. Key: DB_NORTHERN_OBSERVATORY

image
TRSasasusu commented 1 year ago

If we don't use "dgarro.CustomShipLogModes", we don't get this error.

But, if we use "dgarro.CustomShipLogModes", we can get this error with below processes:

  1. get a warp core from ATP
  2. meditate (it leads to a bad ending)
  3. load the previous data
  4. go to your ship log
  5. you see the error

So, I add "dgarro.CustomShipLogModes" into the conflict settings in https://github.com/TRSasasusu/TranslationForTheOutsider/commit/28f7413b0d023cb92b9e1ba1142c4424a1684d21

dgarroDC commented 1 year ago

@TRSasasusu I wanted to figure out what was causing the incompatibility with my mod "dgarro.CustomShipLogModes" to fix it, but I don't think it's something particularly related to that mod. There are some errors logged that come from it but that's just because the bug is preventing the custom modes mod from being initialized and so later operations that it tries to do fail.

I was able to reproduce this bug but just enabling Cheat And Debug Menu (in addition to The Outsider and Translation and Patches for The Outsider). The bug even reproduced without doing the bad ending:

  1. Load a game
  2. Exit to the main menu
  3. Load the game

I installed some random mods and the bug didn't happen (at least not with the steps I gave above), but with Dream World Modding and Debug Assist it happened again.

TRSasasusu commented 1 year ago

@dgarroDC hi, thanks for trying to figure out what causes the error.

The Outsider makes entries by itself in EVERY loading the game: OutsiderShipHandler.cs#L62-L77 So, I think, it would be broken if another mod adds the same entries which are added in the previous loading. Does "dgarro.CustomShipLogModes" have such a procesure?

dgarroDC commented 1 year ago

No, it doesn't modify that object, and I don't think the other 2 mods do that too. So my guess is that The Outsider is the one adding the entries twice sometimes, maybe the comment there that says "resets when return to title for some reason though" isn't always true?

TRSasasusu commented 1 year ago

hmmm... it's so weird.... I didn't encounter with the error without "dgarro.CustomShipLogModes" yet. So, I would consider this problem when someone encounters the error without "dgarro.CustomShipLogModes".

If you can reproduce the error without "dgarro.CustomShipLogModes", please tell me. Thanks.

TRSasasusu commented 1 year ago

Ah, did you say that only Cheat And Debug Menu, The Outsider and Translation and Patches for The Outsider reproduced that error?

ok, I would consider the problem near days (now, i'm busy)

TRSasasusu commented 1 year ago

If you could reproduce the error with only The Outsider and Translation and Patches for The Outsider, please tell me. It would very helpful.

dgarroDC commented 1 year ago

I reproduced with these combinations:

But so far I didn't reproduce with The Outsider and Translation and Patches for The Outsider. I will tell you here if it happens.

dgarroDC commented 1 year ago

Reading about scriptable objects, it seems they might be garbage collected on scene loads if they are not referenced. So when you go to the main menu, the ShipLogLibrary would be freed from memory by the garbage collector, and it would be reloaded from disk (returning to its original state with only vanilla entries). So maybe these other mods are (indirectly) holding references to the ShipLogLibrary and prevents it from being collected, or maybe for some other reason, I don't know.

The Outsider shouldn't probably assume that the ShipLogLibrary is reseted every time we go to the main menu and it should instead check if the entries are already there to avoid the duplicates, maybe a prefix patch for ShipLogLibrary.BuildEntryDataDictionary to remove the duplicates would be needed.

dgarroDC commented 1 year ago

These steps reproduce the error with Custom Ship Log Modes:

  1. Load a game
  2. Open and close the ship log computer
  3. Exit to the main menu
  4. Load the game

This is different from Cheat And Debug Menu and Dream World Modding and Debug Assist. With those mods the bug reproduces even without opening the Ship Log before going to the menu, so it's easier to get the issue with those mods.

What I found is that in Custom Ship Log Modes there is a field ShipLogMode _nextMode that could reference the map or rumor mode, and those modes reference the ShipLogManager, and this object references the ShipLogLibrary. So, if _nextMode is referencing one of the modes when the main menu scene is loaded, the ShipLogLibrary won't be freed from memory by the garbage collector, so it won't be reset. _nextMode is only initialized when you open the ship log computer, so that's why that step is needed to reproduce the bug. I actually tested adding _nextMode = null; on scene load, and that fixed the bug (or at least it didn't reproduce with the steps above), but of course that isn't a real solution because other mods like Cheat And Debug Menu and Dream World Modding and Debug Assist could still trigger the issue.

TRSasasusu commented 1 year ago

Thanks. I think you are correct. So, I would fix it by avoiding the duplication with some prefix patches in next releases.

TRSasasusu commented 1 year ago

@dgarroDC Thank you, v1.1.6 has no conflicts with Custom Ship Log Modes!