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
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
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
Krabs
SRB2
Commits
6ee0398a
Commit
6ee0398a
authored
9 years ago
by
colette
Browse files
Options
Downloads
Patches
Plain Diff
Fix NetVars hook
parent
c9e74678
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/lua_hook.h
+2
-0
2 additions, 0 deletions
src/lua_hook.h
src/lua_hooklib.c
+28
-0
28 additions, 0 deletions
src/lua_hooklib.c
src/lua_script.c
+2
-26
2 additions, 26 deletions
src/lua_script.c
with
32 additions
and
26 deletions
src/lua_hook.h
+
2
−
0
View file @
6ee0398a
...
...
@@ -14,6 +14,7 @@
#include
"r_defs.h"
#include
"d_player.h"
#include
"blua/lua.h"
enum
hook
{
hook_NetVars
=
0
,
...
...
@@ -47,6 +48,7 @@ enum hook {
};
extern
const
char
*
const
hookNames
[];
void
LUAh_NetArchiveHook
(
lua_CFunction
archFunc
);
void
LUAh_MapChange
(
void
);
// Hook for map change (before load)
void
LUAh_MapLoad
(
void
);
// Hook for map load
void
LUAh_PlayerJoin
(
int
playernum
);
// Hook for Got_AddPlayer
...
...
This diff is collapsed.
Click to expand it.
src/lua_hooklib.c
+
28
−
0
View file @
6ee0398a
...
...
@@ -173,6 +173,34 @@ int LUA_HookLib(lua_State *L)
return
0
;
}
void
LUAh_NetArchiveHook
(
lua_CFunction
archFunc
)
{
int
TABLESINDEX
;
hook_p
hookp
;
if
(
!
gL
)
return
;
TABLESINDEX
=
lua_gettop
(
gL
);
lua_settop
(
gL
,
0
);
lua_pushvalue
(
gL
,
TABLESINDEX
);
lua_pushcclosure
(
gL
,
archFunc
,
1
);
lua_pushnil
(
gL
);
for
(
hookp
=
roothook
;
hookp
;
hookp
=
hookp
->
next
)
if
(
hookp
->
type
==
hook_NetVars
)
{
lua_pushfstring
(
gL
,
FMT_HOOKID
,
hookp
->
id
);
lua_gettable
(
gL
,
LUA_REGISTRYINDEX
);
lua_pushvalue
(
gL
,
-
2
);
LUA_Call
(
gL
,
1
);
}
lua_pop
(
gL
,
2
);
}
boolean
LUAh_MobjHook
(
mobj_t
*
mo
,
enum
hook
which
)
{
hook_p
hookp
;
...
...
This diff is collapsed.
Click to expand it.
src/lua_script.c
+
2
−
26
View file @
6ee0398a
...
...
@@ -915,30 +915,6 @@ static void UnArchiveTables(void)
}
}
static
void
NetArchiveHook
(
lua_CFunction
archFunc
)
{
int
TABLESINDEX
;
if
(
!
gL
)
return
;
TABLESINDEX
=
lua_gettop
(
gL
);
lua_getfield
(
gL
,
LUA_REGISTRYINDEX
,
"hook"
);
I_Assert
(
lua_istable
(
gL
,
-
1
));
lua_rawgeti
(
gL
,
-
1
,
hook_NetVars
);
lua_remove
(
gL
,
-
2
);
I_Assert
(
lua_istable
(
gL
,
-
1
));
lua_pushvalue
(
gL
,
TABLESINDEX
);
lua_pushcclosure
(
gL
,
archFunc
,
1
);
lua_pushnil
(
gL
);
while
(
lua_next
(
gL
,
-
3
)
!=
0
)
{
lua_pushvalue
(
gL
,
-
3
);
// function
LUA_Call
(
gL
,
1
);
}
lua_pop
(
gL
,
2
);
}
void
LUA_Step
(
void
)
{
if
(
!
gL
)
...
...
@@ -972,7 +948,7 @@ void LUA_Archive(void)
}
WRITEUINT32
(
save_p
,
UINT32_MAX
);
// end of mobjs marker, replaces mobjnum.
NetArchiveHook
(
NetArchive
);
// call the NetArchive hook in archive mode
LUAh_
NetArchiveHook
(
NetArchive
);
// call the NetArchive hook in archive mode
ArchiveTables
();
if
(
gL
)
...
...
@@ -1003,7 +979,7 @@ void LUA_UnArchive(void)
UnArchiveExtVars
(
th
);
// apply variables
}
while
(
mobjnum
!=
UINT32_MAX
);
// repeat until end of mobjs marker.
NetArchiveHook
(
NetUnArchive
);
// call the NetArchive hook in unarchive mode
LUAh_
NetArchiveHook
(
NetUnArchive
);
// call the NetArchive hook in unarchive mode
UnArchiveTables
();
if
(
gL
)
...
...
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