Improve support for global script targets

Closes #2316 (closed) and #7830 (closed).

Morrowind.exe saves script targets as a RefNum. If the target doesn't have a content file, the saved integer is 0. fromUint32 + decrementing mContentFile is equivalent to using a default constructed (unset) RefNum.

When loading a save with an unset RefNum target in Morrowind.exe, the global script appears to get reassigned to a door marker. Which is nonsensical on several levels, but it seems to do it quite consistently with the specific marker depending on your load order.

When I implemented #2311 (closed), OpenMW didn't have a way of tracking arbitrary objects without content files. I matched Morrowind.exe by not saving the target in this case. Due to Morrowind.exe's weird target reassignment the observed behaviour wasn't identical, but scripts written by people who knew targets could be lost this way worked around it and worked. (With some help from MRs like !4576 (merged).)

!430 (merged) solved the issue of objects without content files not having a RefNum, allowing us to preserve global script targets. This deviates from Morrowind.exe behaviour, but it's essentially just a quality of life improvement given Morrowind.exe's idiosyncrasies. That's to say target reassignment makes it a poor way of detecting if the player has loaded a save, which is the only argument I can think of for not implementing this. Either way it can't really break much as it's equivalent to leaving the game running.

Oh and this doesn't require a save format bump. Older versions will continue to do what they always did.

Edited by Evil Eye

Merge request reports

Loading