shudnal / Seasons

Valheim mod. Adds seasons system.
The Unlicense
3 stars 2 forks source link

Winter Expand World Overspawn Bug #7

Closed wlittlet closed 7 months ago

wlittlet commented 8 months ago

Hi, I just wanted to see if you were already aware of this conflict between Expand World and Seasons. To replicate the issue:

  1. Set day duration in main config file to 15 seconds
  2. Start game with both EW and Seasons installed
  3. Fly over to a mountain
  4. Wait until season changes to winter
  5. About midway through winter, NRE's start to pop up in console, and many creatures and pickable items start duplicating where they stand, causing lag image

If this is not fixable within Seasons, please let me know. Thank you,

shudnal commented 8 months ago

Looks like it tied to moment ocean freezes. I've checked the ExpandWorldData code and my only guess it's some custom object spawning while ocean have unusual solid surface. I don't know if I can provide compatibility. I'll try to but I don't know if it will be possible.

shudnal commented 8 months ago

ExpandWorldData itself have no reason of the error you get. It's the combination of factors. Can you share your configs and settings? Maybe something will catch my sight.

wlittlet commented 8 months ago

https://file.io/04mZiEZ0FoMa

shudnal commented 8 months ago

I've checked the code again and I guess it's ice floes feature. You can try to disable it. Frozen ocean should work but it's the next candidate to disable if the error still persists. Otherwise I have no idea what could go wrong.

wlittlet commented 8 months ago

It seems to still be happening with floes and ocean-freeze disabled in configs. From further testing, it appears to trigger when mountain caves load in (only during winter). MountainCaves-EW-Seasons-Bug

A couple other things I noticed.

  1. If you wait until winter ends, the errors stop
  2. If you are on top of a mountain cave before winter starts and don't move, the error does not trigger
shudnal commented 8 months ago

Ok then it's not ocean and floes obviosly. I have tried to get rid of some redundant code probably would causing the case. Pls check that version. Seasons.zip

shudnal commented 8 months ago

If that doesn't help you can try to add custom prefabs to "ignorePrefab" or "ignorePrefabPartialName" section of Materials.json in Cache settings.

wlittlet commented 8 months ago

While the new Seasons.dll did not fix the issue, I will try adding mountain biome prefabs to the cache settings. Thank you for the quick replies and I'll let you know if I find out what specific prefab is causing it.

shudnal commented 8 months ago

Actually objects located in the mountain, deep north and ashlands are not recolored but if it was tied to that objects then the issue would persist in other seasons. So the issue should be somewhere else.

shudnal commented 8 months ago

ExpandWorldData.zip I've made a change which could be causing the error. Pls check if it helps. I've compiled it from mod's repo. If it helps then it's on EWD side to fix.

shudnal commented 8 months ago

I've checked EWD repo and it already has the same issue from 2 weeks ago. It would be nice to find a way to fix that.

shudnal commented 8 months ago

I've tried to recreate the issue using vanilla settings of EWD with no success.

wlittlet commented 8 months ago

I will test with the new dll file in about 6 hours and let you know. I will notate any additional replicable steps if issue persists, thank you.

mdf25 commented 8 months ago

When I had the error with ExpandWorld I had ice floes turned off and the ocean was not freezing. I think it has to do with the rocks that get coloured white, as sometimes I'd have one randomly spawn in front of me when walking around.

I am thinking if there are prefab variants being created and used for the season in winter, EWD probably doesn't register this in the vegetation file since they are created on the fly and not registered as a vegetation type in the Seasons mod? And so when searching for that instance to generate in a zone, it nullrefs and falls back to spanmming the original prefabs. Just spitballing here but from lookig at it that's my best guess. :D

shudnal commented 8 months ago

The method causing issue is rather small image There is so little room for NRE it's crazy.

image In the version above I've tried to add some bulletproof for zdo check. But that's just a wild try.

shudnal commented 8 months ago

Seasons prefab recoloring works without much interference with other mods or game behavior. Or at least I'm unaware of that. On world load Seasons gets list of prefab names and textures set tied to that prefab. The moment object is spawned in the world its prefab name is checked to be at that collection. And if it is found then basically the reference to that object is stored at another collection and textures and colors are stored within. Then when it's time to recolor then material block is applied to the selected material.

At first I saw Winter and ghostinit mentioned in error text and immediately thought of ice floes as they are ghost initialized. Second was frozen surface potentially breaking block check for another mod. It was an issue when the objects didn't spawn an winter. But the reason was obvious. And disabling frozen ocean and ice floes should be enough.

Last ZNetView objects are being modified at winter are Plant and Pickable. But there is no destructive behavior only callling SetPicked fpr Pickable and WrongBiome status for Plants.

shudnal commented 8 months ago

@mdf25 pls check if the Seasons.zip and ExpandWorldData.zip have any effect in your case.

shudnal commented 8 months ago

That's funny Windows Defender finding trojan in ExpandWorldData.zip

mdf25 commented 8 months ago

Tested them together (I downloaded the Expand_World_Data mod via Thunderstore and left all configs at default apart from time of day set to 15s).

So far, no red text.

Going to install ServerDevCommands to see if flying to other areas causes issues in new biomes. Tested Meadows & Black Forest so far, not a problem yet :)

shudnal commented 8 months ago

Did you test it with ice floes and frozen ocean enabled? I've published 1.1.2 version with mentioned fix. I have no idea what else could be wrong.

mdf25 commented 8 months ago

OK, so tested anoter winter. The exact same issue is still occurring. And yup ice floes are enabled as well as water freezing but I don't have issues out in the ocean (not tested near a leviathan yet though)

I was at Mistlands this time, and those large rock spires are flickering between the regular black colour and the winter snow covered texture whilst the red text is happening.

[Error  : Unity Log] NullReferenceException: Object reference not set to an instance of an object
Stack trace:
ExpandWorldData.DataManager.CleanGhostInit (ZNetView view) (at <a1c3077df485469aa35aab6d721a454d>:0)
ExpandWorldData.DataManager.CleanGhostInit (UnityEngine.GameObject obj) (at <a1c3077df485469aa35aab6d721a454d>:0)
ExpandWorldData.DataManager.Instantiate (UnityEngine.GameObject prefab, UnityEngine.Vector3 pos, UnityEngine.Quaternion rot, Service.ZDOData data) (at <a1c3077df485469aa35aab6d721a454d>:0)
ExpandWorldData.VegetationSpawning.Instantiate (UnityEngine.GameObject prefab, UnityEngine.Vector3 pos, UnityEngine.Quaternion rot, System.Collections.Generic.List`1[T] clearAreas) (at <a1c3077df485469aa35aab6d721a454d>:0)
(wrapper dynamic-method) ZoneSystem.DMD<ZoneSystem::PlaceVegetation>(ZoneSystem,Vector2i,UnityEngine.Vector3,UnityEngine.Transform,Heightmap,System.Collections.Generic.List`1<ZoneSystem/ClearArea>,ZoneSystem/SpawnMode,System.Collections.Generic.List`1<UnityEngine.GameObject>)
ZoneSystem.SpawnZone (Vector2i zoneID, ZoneSystem+SpawnMode mode, UnityEngine.GameObject& root) (at <dbd2a6fbcde9498cadcacfb37ef883e3>:0)
ZoneSystem.CreateGhostZones (UnityEngine.Vector3 refPoint) (at <dbd2a6fbcde9498cadcacfb37ef883e3>:0)
ZoneSystem.Update () (at <dbd2a6fbcde9498cadcacfb37ef883e3>:0)

I will try waiting here without Server Devcommands to make sure that isn't causing a weird issue too, but it shouldn't be as that mod only deals with the console.

I wonder if it's possible to patch the mod's method with a harmony patch to wrap that ExpandWorld method it in a null check and do nothing if null... Not sure if that's possible though.

Edit: It totally is possible to do it. Found this thread that uses Prepare() to check the mod is loaded and gets the target method from that mod. So, in theory, it's doable. https://ludeon.com/forums/index.php?topic=29517.msg448123;topicseen#msg448123

shudnal commented 8 months ago

Could you change the Cache format settings in Test section to SaveBothLoadBinary and share the cache.json file here?

shudnal commented 8 months ago

And I think I need to reproduce it on my side using your custom settings bundle. Or did you still use vanilla EWD settings?

mdf25 commented 8 months ago

Expand World Data was default settings, no changes at all. I just downlaoded the mod from Thunderstore and added it to a blank profile on Valheim latest version with your Seasons zip mod and hit go. I started a new world and just flew around and let it run :)

Here's a video of it, had to move to a new area to make it happen but last time it just happened from flying around. You can see the flicker start up a bit later into the vid, sorry for low quality but needed small file :D Video.zip

Here's the JSONs I have from the mod after adjusting config settings. Defaults.zip

shudnal commented 8 months ago

I've meant \BepInEx\cache\shudnal.Seasons{some number}\cache.json file that should be there. If there is none then run the game and do "resetseasonscache" command in terminal it will take about 30 seconds to build cache. Then you should have a folder with cache.json inside.

I've downloaded https://valheim.thunderstore.io/package/JereKuusela/Expand_World_Data/ and with current https://thunderstore.io/package/download/shudnal/Seasons/1.1.2/ installed I have no issue how much I tried to teleport and fly around both in singleplayer and on dedicated server.

I didn't change anything in EWD and in Seasons I have everything enabled. Still everything works fine.

shudnal commented 8 months ago

Flicker is most likely caused by just the engine can't handle the mess the error make to the game state. And as I see the flickering is there for any object not just rocks. So that's something more general than just wrong prefab application rules.

mdf25 commented 8 months ago

Think this is the right one? cache.json

shudnal commented 8 months ago

That's the right one. And it looks fine. No custom prefabs and no unusual materials.

mdf25 commented 8 months ago

Tested again on a new world and made sure I have the same packages just to be sure.

I noticed the problem only seems to happen in Mistlands now during winter. Still testing more, but I can get it to happen when I go there quite reliably. Teleporting there made it happen instantly from a new world, so going to fly in slowly and see if it still happens when I approach it normally or start winter within the biome.

... and results are in. Left myself in Mistlands and quit out, turned off ServerDevCommands and logged in again with -console parameter to wait for winter - and the issue still happens, at least after I move out of the starting area where I was standing.

If you like I can send another vid showing my whole install process just so you can be sure I've not messed something up, but I don't see how I could have done anything wrong with just 2 mods. But you never know.

shudnal commented 8 months ago

I think video could be handy as I could just reproduce your actions step by step.

shudnal commented 8 months ago

I've managed to reproduce. Tried to make that fix image Now I'm getting bunch of other errors image

shudnal commented 8 months ago

I don't know how that's actually possible but there is somehow objects like cliff_mistlands1(Clone) with ZNetView component with view.GetZDO() == null

I've added Log string image

and now I'm getting this image

shudnal commented 8 months ago

But you know what's even more funny. It's reproducable with Seasons disabled.

mdf25 commented 8 months ago

Weird, does that happen on a new world as well? I've never come across that red error before with just EWD. Wonder why Mistlands rocks have no ZDO data... I'll guess we'll have to wait to see if Jere can fix EWD to account for those nulls :D

shudnal commented 8 months ago

It means ghost zone initialization is broken at some point. And its state persists.

shudnal commented 8 months ago

It's only happening on a new world.

shudnal commented 8 months ago

Also my test character ZDO was reset.

shudnal commented 8 months ago

I disabled Seasons, deleted EWD configs, created a new world and still got the error. Looks like something related to Dungeon or Location initialization. Or idk. Doesn't look like something tied to Seasons. There is one suspicious line right after first wrong prefab init. "Dungeon loaded with 0 rooms from old format in 1,9949 ms." LogOutput.log

shudnal commented 8 months ago

I have no idea what's going on. I've build ExpandWorldData.dll from repo. And that version causes the errors from the start of new world. And Thunderstore version does not. So Seasons 1.1.2 + Thunderstore ExpandWorldData works for me. There are still plenty of issues like not recoloring freshly spawned objects, wrong biome terrain color from time to time so idk if it's reasonable to try to make it fully compatible. There are so much changes Jere made to world building process.

mdf25 commented 8 months ago

Although it's probably more on EWD's side to check, I did manage to get that vid done from a new profile just to show you the errors from a fresh world. Probably not relevant now since you replicated it outside of seasons, but just in case it's in any way helpful. Video2.zip

shudnal commented 7 months ago

Seasons.zip Pls check if the issue persists in that version

mdf25 commented 7 months ago

So far, so good. Tested two winters back to back, and no red text - so definitely looking good. Only thing I noticed now in mistlands is some trees are still green during winter, but I actually kinda like it! :D

shudnal commented 7 months ago

I've fixed it already in the next version.

shudnal commented 7 months ago

Seasons.zip You can check if terrain is properly colored and other objects

shudnal commented 7 months ago

If terrain in Plains remains green in Summer and Fall there is some file in expand_world folder. I didn't seek but deleted them all.

mdf25 commented 7 months ago

Probably in expand_clutter.yml I think :) But seems better in this one, plains grass responded normally to season change and also found no green rocks in mistlands. Still no nullrefs either, so you might just have cracked it! :D

shudnal commented 7 months ago

Looks like this. The fix will be included in the next version as well as some refinements and what's most valuable full EWD compatibility. Thanks for cooperation. You can close the issue on EWD repo as well.

wlittlet commented 7 months ago

I've also confirmed the NRE's are no more! Granted I still have ocean-freeze and ice floes turned off. What was the cause?

shudnal commented 7 months ago

The reason was the call of m_nview.Destroy(); at Pickable.Awake. That's still possible in vanilla game with some unusual circumstances.