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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STJr
SRB2
Commits
e6136eb1
Commit
e6136eb1
authored
4 years ago
by
Monster Iestyn
Browse files
Options
Downloads
Patches
Plain Diff
lua_blockmaplib.c: added "polyobjs" option to searchBlockmap function
also updated my copyright years in this file B)
parent
625aeb15
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!1140
Lua polyobjects
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lua_blockmaplib.c
+55
-1
55 additions, 1 deletion
src/lua_blockmaplib.c
with
55 additions
and
1 deletion
src/lua_blockmaplib.c
+
55
−
1
View file @
e6136eb1
// SONIC ROBO BLAST 2
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Copyright (C) 2016 by Iestyn "Monster Iestyn" Jealous.
// Copyright (C) 2016
-2020
by Iestyn "Monster Iestyn" Jealous.
// Copyright (C) 2016-2020 by Sonic Team Junior.
// Copyright (C) 2016-2020 by Sonic Team Junior.
//
//
// This program is free software distributed under the
// This program is free software distributed under the
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
#include
"doomdef.h"
#include
"doomdef.h"
#include
"p_local.h"
#include
"p_local.h"
#include
"r_main.h"
// validcount
#include
"r_main.h"
// validcount
#include
"p_polyobj.h"
#include
"lua_script.h"
#include
"lua_script.h"
#include
"lua_libs.h"
#include
"lua_libs.h"
//#include "lua_hud.h" // hud_running errors
//#include "lua_hud.h" // hud_running errors
...
@@ -20,6 +21,7 @@
...
@@ -20,6 +21,7 @@
static
const
char
*
const
search_opt
[]
=
{
static
const
char
*
const
search_opt
[]
=
{
"objects"
,
"objects"
,
"lines"
,
"lines"
,
"polyobjs"
,
NULL
};
NULL
};
// a quickly-made function pointer typedef used by lib_searchBlockmap...
// a quickly-made function pointer typedef used by lib_searchBlockmap...
...
@@ -167,6 +169,55 @@ static UINT8 lib_searchBlockmap_Lines(lua_State *L, INT32 x, INT32 y, mobj_t *th
...
@@ -167,6 +169,55 @@ static UINT8 lib_searchBlockmap_Lines(lua_State *L, INT32 x, INT32 y, mobj_t *th
return
0
;
// Everything was checked.
return
0
;
// Everything was checked.
}
}
// Helper function for "polyobjs" search
static
UINT8
lib_searchBlockmap_PolyObjs
(
lua_State
*
L
,
INT32
x
,
INT32
y
,
mobj_t
*
thing
)
{
INT32
offset
;
polymaplink_t
*
plink
;
// haleyjd 02/22/06
if
(
x
<
0
||
y
<
0
||
x
>=
bmapwidth
||
y
>=
bmapheight
)
return
0
;
offset
=
y
*
bmapwidth
+
x
;
// haleyjd 02/22/06: consider polyobject lines
plink
=
polyblocklinks
[
offset
];
while
(
plink
)
{
polyobj_t
*
po
=
plink
->
po
;
if
(
po
->
validcount
!=
validcount
)
// if polyobj hasn't been checked
{
po
->
validcount
=
validcount
;
lua_pushvalue
(
L
,
1
);
LUA_PushUserdata
(
L
,
thing
,
META_MOBJ
);
LUA_PushUserdata
(
L
,
po
,
META_POLYOBJ
);
if
(
lua_pcall
(
gL
,
2
,
1
,
0
))
{
if
(
!
blockfuncerror
||
cv_debug
&
DBG_LUA
)
CONS_Alert
(
CONS_WARNING
,
"%s
\n
"
,
lua_tostring
(
gL
,
-
1
));
lua_pop
(
gL
,
1
);
blockfuncerror
=
true
;
return
0
;
// *shrugs*
}
if
(
!
lua_isnil
(
gL
,
-
1
))
{
// if nil, continue
if
(
lua_toboolean
(
gL
,
-
1
))
return
2
;
// stop whole search
else
return
1
;
// stop block search
}
lua_pop
(
gL
,
1
);
if
(
P_MobjWasRemoved
(
thing
))
return
2
;
}
plink
=
(
polymaplink_t
*
)(
plink
->
link
.
next
);
}
return
0
;
// Everything was checked.
}
// The searchBlockmap function
// The searchBlockmap function
// arguments: searchBlockmap(searchtype, function, mobj, [x1, x2, y1, y2])
// arguments: searchBlockmap(searchtype, function, mobj, [x1, x2, y1, y2])
// return value:
// return value:
...
@@ -195,6 +246,9 @@ static int lib_searchBlockmap(lua_State *L)
...
@@ -195,6 +246,9 @@ static int lib_searchBlockmap(lua_State *L)
case
1
:
// "lines"
case
1
:
// "lines"
searchFunc
=
lib_searchBlockmap_Lines
;
searchFunc
=
lib_searchBlockmap_Lines
;
break
;
break
;
case
2
:
// "polyobjs"
searchFunc
=
lib_searchBlockmap_PolyObjs
;
break
;
}
}
// the mobj we are searching around, the "calling" mobj we could say
// the mobj we are searching around, the "calling" mobj we could say
...
...
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