Revert "Have Lua_OnChange restore the stack to what it was before it was called."

This reverts commit b49a3c6c7d.
This commit is contained in:
Alug committed 2025-10-30 18:03:04 +01:00
1 parent 4ebc8b54ec
commit b70172f0a0
1 file changed
+6 -4
+6 -4
View File
@@ -321,8 +321,11 @@ static void Lua_OnChange(void)
{
/// \todo Network this! XD_LUAVAR
// Why?..
//lua_settop(gL, 0); // Just in case...
lua_pushcfunction(gL, LUA_GetErrorMessage);
lua_insert(gL, 1); // Because LUA_Call wants it at index 1.
int error_handler_i = abs_index(gL, -1);
// From CV_OnChange registry field, get the function for this cvar by name.
lua_getfield(gL, LUA_REGISTRYINDEX, "CV_OnChange");
@@ -332,9 +335,8 @@ static void Lua_OnChange(void)
LUA_RawPushUserdata(gL, this_cvar);
LUA_Call(gL, 1, 0, 1); // call function(cvar)
lua_pop(gL, 1); // pop CV_OnChange table
lua_remove(gL, 1); // remove LUA_GetErrorMessage
LUA_Call(gL, 1, 0, error_handler_i); // call function(cvar)
lua_pop(gL, 2); // pop CV_OnChange table and error handler
}
static int lib_cvRegisterVar(lua_State *L)