1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-23 12:45:43 +02:00

Some map border related fixes

1. Check for entity addition success in spawn_item implementation
2. Check for success in item_drop callback, so that the player
doesn't lose the item if they are outside bounds and try to drop it.
3. When existing player joins game, check that their position is inside
map bounds. If not, set their position to the return value of findSpawnPos().
4. Make findSpawnPos() respect the border

2 fixes a lua crash if a player drops an item outside map bounds.
3 fixes an assertion crash if a player leaves when being outside map bounds,
and then rejoins.
This commit is contained in:
est31
2015-09-29 17:26:07 +02:00
parent 0cde03254a
commit 2a7d01b833
3 changed files with 29 additions and 12 deletions

View File

@@ -349,12 +349,16 @@ function core.item_drop(itemstack, dropper, pos)
v.y = v.y*2 + 2
v.z = v.z*2
obj:setvelocity(v)
return itemstack
end
else
core.add_item(pos, itemstack)
if core.add_item(pos, itemstack) then
return itemstack
end
end
return itemstack
-- If we reach this, adding the object to the
-- environment failed
end
function core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)