mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-21 18:32:08 +00:00
Merge branch 'lua-hook-cleanup' into 'next'
Lua hook cleanup See merge request STJr/SRB2!851
This commit is contained in:
commit
1edc300d0c
2 changed files with 13 additions and 23 deletions
|
@ -80,9 +80,7 @@ struct hook_s
|
|||
UINT16 id;
|
||||
union {
|
||||
mobjtype_t mt;
|
||||
char *skinname;
|
||||
char *musname;
|
||||
char *funcname;
|
||||
char *str;
|
||||
} s;
|
||||
boolean error;
|
||||
};
|
||||
|
@ -151,28 +149,16 @@ static int lib_addHook(lua_State *L)
|
|||
break;
|
||||
case hook_BotAI:
|
||||
case hook_ShouldJingleContinue:
|
||||
hook.s.skinname = NULL;
|
||||
hook.s.str = NULL;
|
||||
if (lua_isstring(L, 2))
|
||||
{ // lowercase copy
|
||||
const char *s = lua_tostring(L, 2);
|
||||
char *p = hook.s.skinname = ZZ_Alloc(strlen(s)+1);
|
||||
do {
|
||||
*p = tolower(*s);
|
||||
++p;
|
||||
} while(*(++s));
|
||||
*p = 0;
|
||||
hook.s.str = Z_StrDup(lua_tostring(L, 2));
|
||||
strlwr(hook.s.str);
|
||||
}
|
||||
break;
|
||||
case hook_LinedefExecute: // Linedef executor functions
|
||||
{ // uppercase copy
|
||||
const char *s = luaL_checkstring(L, 2);
|
||||
char *p = hook.s.funcname = ZZ_Alloc(strlen(s)+1);
|
||||
do {
|
||||
*p = toupper(*s);
|
||||
++p;
|
||||
} while(*(++s));
|
||||
*p = 0;
|
||||
}
|
||||
hook.s.str = Z_StrDup(luaL_checkstring(L, 2));
|
||||
strupr(hook.s.str);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -1075,7 +1061,7 @@ boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
|
|||
for (hookp = roothook; hookp; hookp = hookp->next)
|
||||
{
|
||||
if (hookp->type != hook_BotAI
|
||||
|| (hookp->s.skinname && strcmp(hookp->s.skinname, ((skin_t*)tails->skin)->name)))
|
||||
|| (hookp->s.str && strcmp(hookp->s.str, ((skin_t*)tails->skin)->name)))
|
||||
continue;
|
||||
|
||||
if (lua_gettop(gL) == 0)
|
||||
|
@ -1137,7 +1123,7 @@ boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector)
|
|||
|
||||
for (hookp = linedefexecutorhooks; hookp; hookp = hookp->next)
|
||||
{
|
||||
if (strcmp(hookp->s.funcname, line->text))
|
||||
if (strcmp(hookp->s.str, line->text))
|
||||
continue;
|
||||
|
||||
if (lua_gettop(gL) == 0)
|
||||
|
@ -1675,7 +1661,7 @@ boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname)
|
|||
for (hookp = roothook; hookp; hookp = hookp->next)
|
||||
{
|
||||
if (hookp->type != hook_ShouldJingleContinue
|
||||
|| (hookp->s.musname && strcmp(hookp->s.musname, musname)))
|
||||
|| (hookp->s.str && strcmp(hookp->s.str, musname)))
|
||||
continue;
|
||||
|
||||
if (lua_gettop(gL) == 0)
|
||||
|
|
|
@ -1548,6 +1548,10 @@ boolean P_EvaluateMusicStatus(UINT16 status, const char *musname)
|
|||
int i;
|
||||
boolean result = false;
|
||||
|
||||
#ifndef HAVE_BLUA
|
||||
(void)musname;
|
||||
#endif
|
||||
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
if (!P_IsLocalPlayer(&players[i]))
|
||||
|
|
Loading…
Reference in a new issue