Commit 639b8082d7e7f855b1340aaa1350e5f1548b8aa2

Authored by DarkGod
2 parents 61a3ba1a 4864746c

Merge branch 'mrfrog-darkvision-fix' into 'master'

Mr Frog's fix of darkvision

http://forums.te4.org/viewtopic.php?f=42&t=51778

See merge request !684
... ... @@ -519,18 +519,18 @@ function _M:lineFOV(tx, ty, extra_block, block, sx, sy)
519 519 (game.level.map.lites(tx, ty) or act and self:canSee(act))
520 520
521 521 extra_block = type(extra_block) == "function" and extra_block
522   - or type(extra_block) == "string" and function(_, x, y) return game.level.map:checkAllEntities(x, y, extra_block) end
  522 + or type(extra_block) == "string" and function(self, x, y) return game.level.map:checkAllEntities(x, y, extra_block, self) end
523 523
524 524 block = block
525 525 or sees_target and function(_, x, y)
526   - return game.level.map:checkAllEntities(x, y, "block_sight") or
527   - game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "block_move") and not game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "pass_projectile") or
  526 + return game.level.map:checkAllEntities(x, y, "block_sight", self) or
  527 + game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "block_move", self) and not game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "pass_projectile") or
528 528 extra_block and extra_block(self, x, y)
529 529 end
530 530 or function(_, x, y)
531 531 if (self.sight and core.fov.distance(sx, sy, x, y) <= self.sight or not self.sight) and game.level.map.lites(x, y) then
532   - return game.level.map:checkEntity(x, y, Map.TERRAIN, "block_sight") or
533   - game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "block_move") and not game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "pass_projectile") or
  532 + return game.level.map:checkEntity(x, y, Map.TERRAIN, "block_sight", self) or
  533 + game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "block_move", self) and not game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "pass_projectile") or
534 534 extra_block and extra_block(self, x, y)
535 535 else
536 536 return true
... ...
... ... @@ -167,15 +167,15 @@ function _M:lineFOV(tx, ty, extra_block, block, sx, sy)
167 167 act and self:canSee(act) and core.fov.distance(sx, sy, tx, ty) <= math.min(self.sight, math.max(self.heightened_senses or 0, self.infravision or 0))
168 168
169 169 extra_block = type(extra_block) == "function" and extra_block
170   - or type(extra_block) == "string" and function(_, x, y) return game.level.map:checkAllEntities(x, y, extra_block) end
  170 + or type(extra_block) == "string" and function(self, x, y) return game.level.map:checkAllEntities(x, y, extra_block, self) end
171 171
172 172 -- This block function can be called *a lot*, so every conditional statement we move outside the function helps
173 173 block = block or sees_target and
174 174 -- target is NOT seen
175 175 function(_, x, y)
176 176 if core.fov.distance(sx, sy, x, y) <= self.sight and game.level.map.lites(x, y) then
177   - return game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "block_sight") or
178   - game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "block_move") and not game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "pass_projectile") or
  177 + return game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "block_sight", self) or
  178 + game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "block_move", self) and not game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "pass_projectile", self) or
179 179 extra_block and extra_block(self, x, y)
180 180 else
181 181 return true
... ...
... ... @@ -758,16 +758,16 @@ function _M:lineFOV(tx, ty, extra_block, block, sx, sy)
758 758 local sees_target = game.level.map.seens(tx, ty)
759 759
760 760 extra_block = type(extra_block) == "function" and extra_block
761   - or type(extra_block) == "string" and function(_, x, y) return game.level.map:checkAllEntities(x, y, extra_block) end
  761 + or type(extra_block) == "string" and function(self, x, y) return game.level.map:checkAllEntities(x, y, extra_block, self) end
762 762
763 763 block = block or function(_, x, y)
764 764 if sees_target then
765   - return game.level.map:checkAllEntities(x, y, "block_sight") or
766   - game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "block_move") and not game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "pass_projectile") or
  765 + return game.level.map:checkAllEntities(x, y, "block_sight", self) or
  766 + game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "block_move", self) and not game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "pass_projectile") or
767 767 extra_block and extra_block(self, x, y)
768 768 elseif core.fov.distance(sx, sy, x, y) <= self.sight and (game.level.map.remembers(x, y) or game.level.map.seens(x, y)) then
769   - return game.level.map:checkEntity(x, y, Map.TERRAIN, "block_sight") or
770   - game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "block_move") and not game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "pass_projectile") or
  769 + return game.level.map:checkEntity(x, y, Map.TERRAIN, "block_sight", self) or
  770 + game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "block_move", self) and not game.level.map:checkEntity(x, y, engine.Map.TERRAIN, "pass_projectile") or
771 771 extra_block and extra_block(self, x, y)
772 772 else
773 773 return true
... ...