Fix minetest.clear_* creating new LOCAL table instead of clearing the existing one.
authorTomas Brod <tomasbrod@azet.sk>
Thu, 16 Apr 2015 22:38:28 +0000 (00:38 +0200)
committerkwolekr <kwolekr@minetest.net>
Sun, 26 Apr 2015 19:45:58 +0000 (15:45 -0400)
On calling clear_redistered_biomes the registered_biomes table is cleared
by creating a new empty table, but the pointer is not updated to point to
the new one. So after calling more register_biome, the registered_biome
table always contains 0 items, which is an error. Instead, the table is
cleared by removing all its items so the pointer (minetest.registered_*)
remains valid.

builtin/game/register.lua

index f286113ec8d335bd20c0ade04e78bbcd001c1790..cb084024169d33cc4cebb5ad6ae4fadb50bd3741 100644 (file)
@@ -398,7 +398,9 @@ local function make_registration_wrap(reg_fn_name, clear_fn_name)
 
        local orig_clear_fn = core[clear_fn_name]
        core[clear_fn_name] = function()
-               list = {}
+               for k in pairs(list) do
+                       list[k] = nil
+               end
                return orig_clear_fn()
        end