fixed crash when picking block outside map

This commit is contained in:
BR 2012-12-17 20:05:22 -08:00
parent 544745cc42
commit 0c5c69e695
2 changed files with 8 additions and 4 deletions

View File

@ -438,7 +438,9 @@ end
function map_block_pick(x,y,z)
local xlen,ylen,zlen
xlen,ylen,zlen = common.map_get_dims()
if x < 0 or x >= xlen then return end
if y < 0 or y >= ylen then return end
if z < 0 or z >= zlen then return end
local t = map_pillar_raw_get(x,z)
local c = t[y+1]

View File

@ -714,10 +714,12 @@ function new_player(settings)
if this.tool == TOOL_BLOCK and this.blx3 and this.alive then
local ct,cr,cg,cb
ct,cr,cg,cb = map_block_pick(this.blx3, this.bly3, this.blz3)
this.blk_color = {cr,cg,cb}
common.net_send(nil, common.net_pack("BBBBB",
0x18, 0x00,
this.blk_color[1],this.blk_color[2],this.blk_color[3]))
if ct ~= nil then
this.blk_color = {cr,cg,cb}
common.net_send(nil, common.net_pack("BBBBB",
0x18, 0x00,
this.blk_color[1],this.blk_color[2],this.blk_color[3]))
end
this.ev_rmb = false
elseif this.tool == TOOL_SPADE and this.blx2 and this.alive then
if (not this.t_newspade2) then