diff options
author | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2016-10-24 09:49:41 +0200 |
---|---|---|
committer | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2016-10-24 09:49:41 +0200 |
commit | 1c9bdfad03ab7247ccb55158988ab28929738681 (patch) | |
tree | 6d578100c47060f0a4f55ebc35168a5cc475eea3 | |
parent | dcbf1fce1e9303a00be15451e1802c2d4004070f (diff) | |
download | apartment-1c9bdfad03ab7247ccb55158988ab28929738681.tar.gz apartment-1c9bdfad03ab7247ccb55158988ab28929738681.tar.bz2 apartment-1c9bdfad03ab7247ccb55158988ab28929738681.zip |
Deal with apartment database corruption.
-rw-r--r-- | init.lua | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -943,12 +943,15 @@ if apartment_give_player then minetest.register_on_newplayer(function(player) for k,v in pairs( apartment.apartments ) do if (v.owner == '' and v.category == 'apartment') then - if (apartment.rent( v.pos, player:get_player_name(), nil, player )) then + local meta = minetest.get_meta( v.pos ); + local node = minetest.get_node( v.pos ); + if (node.name == 'apartment:apartment_free' and apartment.rent( v.pos, player:get_player_name(), nil, player )) then player:moveto( v.pos, false); - local meta = minetest.get_meta( v.pos ); meta:set_string( 'formspec', apartment.get_formspec( v.pos, player )); minetest.chat_send_player(player:get_player_name(),"Welcome to your new apartment. You can return here by saying '/aphome'") break + elseif node.name == 'apartment:apartment_occupied' then -- Possible case of database corruption... + apartment.apartments[k] = nil end end end |