Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parallax exception when multiple parallax mods are installed #23

Merged
merged 1 commit into from Apr 17, 2024

Conversation

JonnyOThan
Copy link
Contributor

Installing Kcalbeloh, Parallax, OPM, and OPM_Parallax results in this exception:

[LOG 16:45:41.252] [Parallax] Parsing Onrefni on core
[LOG 16:45:41.252] [Parallax] Created body: Onrefni
[EXC 16:45:41.253] ArgumentException: An item with the same key has already been added. Key: Onrefni
    System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <9577ac7a62ef43179789031239ba8798>:0)
    System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <9577ac7a62ef43179789031239ba8798>:0)
    Parallax.Loader.LoadAllNodes () (at <40e34d3c09734e828597afb2f90e2e92>:0)
    Parallax.Loader.Start () (at <40e34d3c09734e828597afb2f90e2e92>:0)
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
    UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)

I'm not sure what else might be affected but it's pretty clear that this code has no guards against this kind of exception, so it's going to skip all the rest of the config nodes: https://github.com/Gameslinx/Tessellation/blob/bc27cb8ec5dd33b335b3eb42e11fa75046dad180/ParallaxLoader.cs#L123

This error occurs because the @ patch at the top level applies to all nodes unlike when it occurs inside a node. OPM_Parallax adds a second Parallax top-level node for the OPM bodies, so the kcalbeloh patches apply to both:

[LOG 16:41:37.559] Applying update KcalbelohSystem/Parallax/ParallaxTerrain/@Parallax:FOR[KcalbelohSystem]:NEEDS[Parallax_StockTextures] to OPM_Parallax/ParallaxTerrain.cfg/Parallax
[LOG 16:41:37.562] Applying update KcalbelohSystem/Parallax/ParallaxTerrain/@Parallax:FOR[KcalbelohSystem]:NEEDS[Parallax_StockTextures] to Parallax_StockTextures/ParallaxTerrain.cfg/Parallax

Installing Kcalbeloh, Parallax, OPM, and OPM_Parallax results in this exception:

```
[LOG 16:45:41.252] [Parallax] Parsing Onrefni on core
[LOG 16:45:41.252] [Parallax] Created body: Onrefni
[EXC 16:45:41.253] ArgumentException: An item with the same key has already been added. Key: Onrefni
    System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <9577ac7a62ef43179789031239ba8798>:0)
    System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <9577ac7a62ef43179789031239ba8798>:0)
    Parallax.Loader.LoadAllNodes () (at <40e34d3c09734e828597afb2f90e2e92>:0)
    Parallax.Loader.Start () (at <40e34d3c09734e828597afb2f90e2e92>:0)
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
    UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)
```

I'm not sure what else might be affected but it's pretty clear that this code has no guards against this kind of exception, so it's going to skip all the rest of the config nodes: https://github.com/Gameslinx/Tessellation/blob/bc27cb8ec5dd33b335b3eb42e11fa75046dad180/ParallaxLoader.cs#L123

This error occurs because the `@` patch at the top level applies to all nodes unlike when it occurs inside a node.  OPM_Parallax adds a second `Parallax` top-level node for the OPM bodies, so the kcalbeloh patches apply to both:

```
[LOG 16:41:37.559] Applying update KcalbelohSystem/Parallax/ParallaxTerrain/@parallax:FOR[KcalbelohSystem]:NEEDS[Parallax_StockTextures] to OPM_Parallax/ParallaxTerrain.cfg/Parallax
[LOG 16:41:37.562] Applying update KcalbelohSystem/Parallax/ParallaxTerrain/@parallax:FOR[KcalbelohSystem]:NEEDS[Parallax_StockTextures] to Parallax_StockTextures/ParallaxTerrain.cfg/Parallax
```
@jcyuan06 jcyuan06 merged commit e5b1c90 into jcyuan06:main Apr 17, 2024
@JonnyOThan JonnyOThan deleted the patch-1 branch April 17, 2024 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants