Skip to content
Snippets Groups Projects
Commit 0fe98937 authored by dg's avatar dg
Browse files

fix

git-svn-id: http://svn.net-core.org/repos/t-engine4@2071 51575b47-30f0-44d4-a5cc-537603b46e54
parent 670702a6
No related branches found
No related tags found
No related merge requests found
......@@ -112,7 +112,7 @@ function _M:computeFOV(radius, block, apply, force, no_store, cache)
fov.actors_dist[#fov.actors_dist+1] = a
a.__sqdist = sqdist
a:check("seen_by", self)
-- a:updateFOV(self, t.sqdist)
a:updateFOV(self, t.sqdist)
end
end, cache and game.level.map._fovcache[block])
......@@ -138,17 +138,9 @@ function _M:updateFOV(a, sqdist)
-- If we are from this turn no need to update
if self.fov_last_turn == game.turn then return end
local t = {x=a.x, y=a.y, dx=a.x-self.x, dy=a.y-self.y, sqdist=sqdist}
local fov = self.fov
if not fov.actors[a] then
fov.actors_dist[#fov.actors_dist+1] = a
end
fov.actors[a] = t
-- print("Updated FOV for", self.uid, self.name, ":: seen ", #fov.actors_dist, "actors closeby; from", a, sqdist)
table.sort(fov.actors_dist, function(a, b) if a and b then return fov.actors[a].sqdist < fov.actors[b].sqdist elseif a then return 1 else return nil end end)
-- table.sort(fov.actors_dist, "__sqdist")
self.fov_last_change = game.turn
-- Force regen
self.fov_last_x = -1
self.fov_last_y = -1
end
function _M:distanceMap(x, y, v)
......
......@@ -356,7 +356,7 @@ static void map_default_seen(void *m, int x, int y, int dx, int dy, int radius,
// Check if dead
lua_pushstring(L, "dead");
lua_gettable(L, -2);
if (!lua_isnil(L, -1)) { lua_pop(L, 3); return; }
if (lua_toboolean(L, -1)) { lua_pop(L, 3); return; }
lua_pop(L, 1);
// Set sqdist in the actor for faster sorting
......@@ -381,9 +381,6 @@ static void map_default_seen(void *m, int x, int y, int dx, int dy, int radius,
lua_pushstring(L, "sqdist");
lua_pushnumber(L, sqdist);
lua_rawset(L, -3);
lua_pushstring(L, "dist");
lua_pushnumber(L, dist);
lua_rawset(L, -3);
// Set the actor table
lua_pushvalue(L, -2);
......@@ -396,6 +393,14 @@ static void map_default_seen(void *m, int x, int y, int dx, int dy, int radius,
lua_pushvalue(L, -3);
lua_rawset(L, STACK_DIST);
// Call seen_by, if possible
lua_pushstring(L, "updateFOV");
lua_gettable(L, -3);
lua_pushvalue(L, -3);
lua_pushvalue(L, STACK_SELF);
lua_pushnumber(L, sqdist);
lua_call(L, 3, 0);
// Call seen_by, if possible
lua_pushstring(L, "seen_by");
lua_gettable(L, -3);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment