Skip to content

Actor.canSee fix

Samuel Wegner requested to merge Effigy/t-engine4:cansee_fix into master

Set can_see_cache to weak table

Previously, if the "can_see_cache" property is not initialized when Actor.canSee() is called, it will be set to a strong table. This seems bad because this table can hold references to other actors and possibly prevent garbage collection. Actor.resetCanSeeCache() sets "can_see_cache" to a weak table, so I think the same should be done for initializing the property in Actor.canSee().

Now, Actor.canSee() will initialize "can_see_cache" with a weak table if it doesn't already exist.

I stumbled across this while investigating the Warden's Call memory leak and found references to the clones in game.player.can_see_cache. Unfortunately, this change doesn't seem to fix that problem.

Merge request reports