Skip to content
This repository was archived by the owner on Jun 24, 2023. It is now read-only.
This repository was archived by the owner on Jun 24, 2023. It is now read-only.

Add warning for uses of "RegisterForUpdate" #15

@JonathanTaylor555

Description

@JonathanTaylor555

RegisterForUpdate is a function that in almost all cases can be replaced by the safer RegisterForSingleUpdate. A nice feature would be a warning for anyone who uses this function, so they can consider using RegisterForSingleUpdate instead.

Highlights of the issue for RegisterForUpdate from the papyrus wiki, rewritten for simplification:

  • If a mod is removed, its OnUpdate handler will still be registered and the game engine will continue to try to invoke it.
  • Even if your mod still exists, you may not exclude the possibility that a bug manifests itself and causes periodic errors. A better behavior if your event handler contains a bug would be to cancel the automatic updates, which is achieved through RegisterForSingleUpdate.
  • Modifying the OnUpdate handler has no effect: as long as the old handler was registered, it will continue to be used unless you explicitly unregister for updates, then register again.
  • If the OnUpdate handler takes longer than the interval specified in RegisterForUpdate, the event calls can stack, causing stack dumps, save game bloat, script lag, etc.

Using RegisterForSingleUpdate can avoid all those problems, and is the preferred alternative to RegisterForUpdate for most use cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions