diff --git a/JotunnModStub/Fenrir/FenrirBehaviors.cs b/JotunnModStub/Fenrir/FenrirBehaviors.cs index 86d25fc..9b13a35 100644 --- a/JotunnModStub/Fenrir/FenrirBehaviors.cs +++ b/JotunnModStub/Fenrir/FenrirBehaviors.cs @@ -214,36 +214,26 @@ namespace RacesOfValheim } /// - /// Spawns a sound prefab without letting it write itself into the save. + /// Spawns a sound prefab the way the game's own EffectList.Create does: a plain Instantiate. /// - /// SOME VANILLA SOUND PREFABS CARRY A ZNetView. "sfx_fenring_alerted" is one - the Describe - /// line below printed it, which is how this was noticed. A ZNetView that wakes with no init - /// ZDO calls ZDOMan.CreateNewZDO at its position, marks itself persistent, stamps itself with - /// the prefab hash and registers with the scene. On a sound played every time somebody howls - /// or swings a claw, that is one persistent "there is a noise here" record per swing, saved - /// with the world. It is the same bug that left burnt-in torches in people's worlds; the long - /// version is on SkeletonVisuals.BorrowEffect. + /// THIS USED TO WRAP THE INSTANTIATE IN ZNetView GHOST INIT, and that was wrong. Some vanilla + /// sound and effect prefabs carry a ZNetView ("sfx_fenring_alerted" does), and the fear was + /// one persistent ZDO per play left in the save. The ones logged so far also carry + /// TimedDestruction, which ends in ZNetScene.Destroy, and that deletes the ZDO. They are + /// network effects by design, which is how other players hear them. /// - /// ZNetView.StartGhostInit is the game's own answer, not ours: between the two calls a - /// ZNetView comes up with no ZDO at all. Cheaper and far less invasive than stripping the - /// component off a copy, and free on the prefabs that carry no ZNetView. - /// - /// The finally matters. Leaving ghost init switched on because an Instantiate threw would - /// break every ZNetView created afterwards, for the rest of the session. + /// Ghost init does not prevent the ZDO either. Read off ZNetView.Awake: it still calls + /// CreateNewZDO and only skips ZNetScene.AddInstance. That leaves the ZDO with Created=false, + /// and ZNetScene.CreateObjectsSorted builds a second copy of the object from it. Vanilla + /// uses ghost init for zone generation, where the ZDOs are the point and the objects are not. + /// The switch that really yields no ZDO is m_forceDisableInit, which is for item icons and + /// inventory copies, not for anything meant to be seen or heard by others. /// public static void Spawn(GameObject prefab, Vector3 position) { if (prefab == null) return; - ZNetView.StartGhostInit(); - try - { - Object.Instantiate(prefab, position, Quaternion.identity); - } - finally - { - ZNetView.FinishGhostInit(); - } + Object.Instantiate(prefab, position, Quaternion.identity); // NOT FOLLOWED BY A Play() CALL, and that took a while to establish. ZSFX is ticked by // CustomUpdate rather than Unity's Update, so it starts on a later frame: reading diff --git a/JotunnModStub/Fenrir/FormAnimEventSound.cs b/JotunnModStub/Fenrir/FormAnimEventSound.cs index 4fdea87..3a2ee51 100644 --- a/JotunnModStub/Fenrir/FormAnimEventSound.cs +++ b/JotunnModStub/Fenrir/FormAnimEventSound.cs @@ -81,8 +81,7 @@ namespace RacesOfValheim if (!audible) return; - // Through the same ghost-init spawn as everything else here: some vanilla sound prefabs - // carry a ZNetView, and this one fires every time the animation comes round. + // Through the same spawn as every other Fenrir sound, so a change there reaches this too. FenrirCreatureSound.Spawn(prefab, transform.position); } }