api.lua:5: attempt to index local 'pos' (a nil value)

This was suggested by RBA to fix the follow.
```
18:43:28: ACTION[ServerThread]: Sofia punches object -27616: LuaEntitySAO at (13.9607,18.7545,-77.3249)
18:43:41: ERROR[main]: ERROR: An unhandled exception occurred: /home/minetest/Server/bin/../mods/areas/api.lua:5: attempt to index local 'pos' (a nil value)
18:43:41: ERROR[main]: stack traceback:
18:43:41: ERROR[main]:  /home/minetest/Server/bin/../mods/areas/api.lua:5: in function 'getAreasAtPos'
18:43:41: ERROR[main]:  /home/minetest/Server/bin/../mods/areas/legacy.lua:101: in function 'HasOwner'
18:43:41: ERROR[main]:  ...inetest/Server/bin/../mods/plantlife/plants_lib/init.lua:448: in function 'node_is_owned'
18:43:41: ERROR[main]:  ...etest/Server/bin/../mods/plantlife/flowers_plus/init.lua:97: in function <...etest/Server/bin/../mods/plantlife/flowers_plus/init.lua:74>

In thread b693a220:
/home/minetest/Server/src/main.cpp:1870: int main(int, char**): Assertion '0' failed.
Debug stacks:
DEBUG STACK FOR THREAD b20ff440:
#0  virtual void* CurlFetchThread::Thread()
DEBUG STACK FOR THREAD b693a220:
#0  int main(int, char**)
(Leftover data: #1  Dedicated server branch)
(Leftover data: #2  virtual void ServerMap::save(ModifiedState))
(Leftover data: #3  virtual void Database_SQLite3::saveBlock(MapBlock*))
(Leftover data: #4  void ItemStack::serialize(std::ostream&) const)
Aborted
```

I did not test that yet, will comment again here when tested.
This commit is contained in:
Megaf 2014-06-22 20:42:26 -03:00
parent bfb260d181
commit c876179024

View File

@ -2,6 +2,7 @@
-- Returns a list of areas that include the provided position -- Returns a list of areas that include the provided position
function areas:getAreasAtPos(pos) function areas:getAreasAtPos(pos)
local a = {} local a = {}
if pos then
local px, py, pz = pos.x, pos.y, pos.z local px, py, pz = pos.x, pos.y, pos.z
for id, area in pairs(self.areas) do for id, area in pairs(self.areas) do
local ap1, ap2 = area.pos1, area.pos2 local ap1, ap2 = area.pos1, area.pos2
@ -11,6 +12,7 @@ function areas:getAreasAtPos(pos)
a[id] = area a[id] = area
end end
end end
end
return a return a
end end