Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tales of MajEyal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lisa Greene
Tales of MajEyal
Commits
0fe98937
Commit
0fe98937
authored
14 years ago
by
dg
Browse files
Options
Downloads
Patches
Plain Diff
fix
git-svn-id:
http://svn.net-core.org/repos/t-engine4@2071
51575b47-30f0-44d4-a5cc-537603b46e54
parent
670702a6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
game/engines/default/engine/interface/ActorFOV.lua
+4
-12
4 additions, 12 deletions
game/engines/default/engine/interface/ActorFOV.lua
src/fov.c
+9
-4
9 additions, 4 deletions
src/fov.c
with
13 additions
and
16 deletions
game/engines/default/engine/interface/ActorFOV.lua
+
4
−
12
View file @
0fe98937
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
src/fov.c
+
9
−
4
View file @
0fe98937
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment