Stop using metatables with light userdata
- May 03, 2021
-
See !583 (merged), !754 (merged) and !1238 (merged). At the time I did not realize that light userdata metatables are not unique to each value. (Recently it was discovered that accessing the skin sprites list would override the metatable of a cvar from CV_FindVar
.)
I started using light userdata because Lua CV_RegisterVar
would allocate the cvar as userdata, meaning CV_FindVar
wouldn't be able to return a reference to any cvar that wasn't registered by Lua. Well, not without making it use LUA_PushUserdata
, that's what I did here.
See 7df6a309 and 83a87042. I didn't realize that light userdata's metatable is shared--like numbers or strings. So it cannot be paired with a metatable. I also made a few minor tweaks to Lua cvars, other than accounting for the double pointer in the userdata.
This reverts commit d4c08a84, reversing changes made to e100f21d.