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