Issue Data
|
Issue #28300: TrapTriggerBase never clears lastTriggerRef property, causing undue persistence
Just noticed this while poking around a save with ReSaver:
When either of the OnTriggerEnter blocks in TrapTriggerBase fire, the ref that tripped the trap is stored in lastTriggerRef. This property is never used directly in this script, but it is used by some scripts that either extend, or reference TrapTriggerBase. All uses of this property seem to only happen very shortly after the property is assigned, in most cases in the onBeginState block in the extending script's Active state (set immediately after assigning lastTriggerRef), so it seems that this property wasn't intended to be used for long-term memory anyway. Anyway, I notice that lastTriggerRef is never cleared, which means that any actor (or other objectref I suppose) that sets off any trap that uses this script—which is, well, most of them—will remain persistent until something else sets off the same trap, causing unnecessary memory usage and so on. I think a reasonable fix would be to just add a simple OnCellDetach block to the script, like so event OnCellDetach() lastTriggerRef = None endEvent This...shouldn't cause any side-effects, at least based on my own quick analysis of this and related scripts, but would need some testing to be sure. |
I checked all of the scripts using this as a base and the only one that didn't already have a safeguard in place was SpringTrap. So it should be pretty safe to have it go ahead and set lastTriggerRef to None along with a safeguard check in SpringTrap to prevent it from trying to act on the reference if it was being processed when the cell detaches.
Showing Comments 1 - 1 of 1