Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
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
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STJr
SRB2
Commits
5abdb08a
Commit
5abdb08a
authored
Jan 20, 2016
by
Monster Iestyn
Browse files
Options
Downloads
Patches
Plain Diff
#sector.lines now returns the number of linedefs in the sector
parent
79e3e235
No related branches found
No related tags found
1 merge request
!32
Lua sector lines
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lua_maplib.c
+20
-0
20 additions, 0 deletions
src/lua_maplib.c
with
20 additions
and
0 deletions
src/lua_maplib.c
+
20
−
0
View file @
5abdb08a
...
@@ -306,6 +306,23 @@ static int sectorlines_get(lua_State *L)
...
@@ -306,6 +306,23 @@ static int sectorlines_get(lua_State *L)
return
1
;
return
1
;
}
}
static
int
sectorlines_num
(
lua_State
*
L
)
{
line_t
**
seclines
=
*
((
line_t
***
)
luaL_checkudata
(
L
,
1
,
META_SECTORLINES
));
size_t
numoflines
=
0
;
// check first linedef to figure which of its sectors owns this sector->lines pointer
// then check that sector's linecount to get a maximum index
//if (!seclines[0])
//return luaL_error(L, "no lines found!"); // no first linedef?????
if
(
seclines
[
0
]
->
frontsector
->
lines
==
seclines
)
numoflines
=
seclines
[
0
]
->
frontsector
->
linecount
;
else
if
(
seclines
[
0
]
->
backsector
&&
seclines
[
0
]
->
backsector
->
lines
==
seclines
)
// check backsector exists first
numoflines
=
seclines
[
0
]
->
backsector
->
linecount
;
//if neither sector has it then ???
lua_pushinteger
(
L
,
numoflines
);
return
1
;
}
static
int
sector_get
(
lua_State
*
L
)
static
int
sector_get
(
lua_State
*
L
)
{
{
sector_t
*
sector
=
*
((
sector_t
**
)
luaL_checkudata
(
L
,
1
,
META_SECTOR
));
sector_t
*
sector
=
*
((
sector_t
**
)
luaL_checkudata
(
L
,
1
,
META_SECTOR
));
...
@@ -1282,6 +1299,9 @@ int LUA_MapLib(lua_State *L)
...
@@ -1282,6 +1299,9 @@ int LUA_MapLib(lua_State *L)
luaL_newmetatable
(
L
,
META_SECTORLINES
);
luaL_newmetatable
(
L
,
META_SECTORLINES
);
lua_pushcfunction
(
L
,
sectorlines_get
);
lua_pushcfunction
(
L
,
sectorlines_get
);
lua_setfield
(
L
,
-
2
,
"__index"
);
lua_setfield
(
L
,
-
2
,
"__index"
);
lua_pushcfunction
(
L
,
sectorlines_num
);
lua_setfield
(
L
,
-
2
,
"__len"
);
lua_pop
(
L
,
1
);
lua_pop
(
L
,
1
);
luaL_newmetatable
(
L
,
META_SECTOR
);
luaL_newmetatable
(
L
,
META_SECTOR
);
...
...
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