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
bb08b55b
Commit
bb08b55b
authored
5 years ago
by
ChaoLoveIceMDBoy
Browse files
Options
Downloads
Patches
Plain Diff
Created GameQuit hook, but I need to decide where to execute it
parent
ddc0762e
Branches
Branches containing commit
No related tags found
1 merge request
!847
GameQuit Hook
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lua_hook.h
+2
-0
2 additions, 0 deletions
src/lua_hook.h
src/lua_hooklib.c
+24
-0
24 additions, 0 deletions
src/lua_hooklib.c
with
26 additions
and
0 deletions
src/lua_hook.h
+
2
−
0
View file @
bb08b55b
...
@@ -58,6 +58,7 @@ enum hook {
...
@@ -58,6 +58,7 @@ enum hook {
hook_ViewpointSwitch
,
hook_ViewpointSwitch
,
hook_SeenPlayer
,
hook_SeenPlayer
,
hook_PlayerThink
,
hook_PlayerThink
,
hook_GameQuit
,
hook_MAX
// last hook
hook_MAX
// last hook
};
};
...
@@ -110,5 +111,6 @@ UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean
...
@@ -110,5 +111,6 @@ UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean
boolean
LUAh_SeenPlayer
(
player_t
*
player
,
player_t
*
seenfriend
);
// Hook for MT_NAMECHECK
boolean
LUAh_SeenPlayer
(
player_t
*
player
,
player_t
*
seenfriend
);
// Hook for MT_NAMECHECK
#endif
#endif
#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink
#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink
void
LUAh_GameQuit
(
void
);
// Hook for game quitting
#endif
#endif
This diff is collapsed.
Click to expand it.
src/lua_hooklib.c
+
24
−
0
View file @
bb08b55b
...
@@ -69,6 +69,7 @@ const char *const hookNames[hook_MAX+1] = {
...
@@ -69,6 +69,7 @@ const char *const hookNames[hook_MAX+1] = {
"ViewpointSwitch"
,
"ViewpointSwitch"
,
"SeenPlayer"
,
"SeenPlayer"
,
"PlayerThink"
,
"PlayerThink"
,
"GameQuit"
,
NULL
NULL
};
};
...
@@ -1660,4 +1661,27 @@ boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend)
...
@@ -1660,4 +1661,27 @@ boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend)
}
}
#endif // SEENAMES
#endif // SEENAMES
// Hook for game quitting
void
LUAh_GameQuit
(
void
)
{
hook_p
hookp
;
if
(
!
gL
||
!
(
hooksAvailable
[
hook_GameQuit
/
8
]
&
(
1
<<
(
hook_GameQuit
%
8
))))
return
;
for
(
hookp
=
roothook
;
hookp
;
hookp
=
hookp
->
next
)
{
if
(
hookp
->
type
!=
hook_GameQuit
)
continue
;
lua_pushfstring
(
gL
,
FMT_HOOKID
,
hookp
->
id
);
lua_gettable
(
gL
,
LUA_REGISTRYINDEX
);
if
(
lua_pcall
(
gL
,
0
,
0
,
0
))
{
if
(
!
hookp
->
error
||
cv_debug
&
DBG_LUA
)
CONS_Alert
(
CONS_WARNING
,
"%s
\n
"
,
lua_tostring
(
gL
,
-
1
));
lua_pop
(
gL
,
1
);
hookp
->
error
=
true
;
}
}
}
#endif
#endif
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