Merge lua_hooklib.c

This commit is contained in:
SteelT 2020-08-10 12:28:00 -04:00
parent f2967d30d3
commit d502ca31cb

View file

@ -1364,15 +1364,13 @@ boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg, int mute)
else else
lua_pushboolean(gL, false); lua_pushboolean(gL, false);
} }
<<<<<<< HEAD PushHook(gL, hookp);
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_pushvalue(gL, -6); lua_pushvalue(gL, -6);
lua_pushvalue(gL, -6); lua_pushvalue(gL, -6);
lua_pushvalue(gL, -6); lua_pushvalue(gL, -6);
lua_pushvalue(gL, -6); lua_pushvalue(gL, -6);
lua_pushvalue(gL, -6); lua_pushvalue(gL, -6);
if (lua_pcall(gL, 5, 1, 0)) { if (lua_pcall(gL, 4, 1, 1)) {
if (!hookp->error || cv_debug & DBG_LUA) if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1); lua_pop(gL, 1);
@ -1381,29 +1379,12 @@ boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg, int mute)
} }
if (lua_toboolean(gL, -1)) if (lua_toboolean(gL, -1))
hooked = true; hooked = true;
=======
lua_pushstring(gL, msg); // msg
}
PushHook(gL, hookp);
lua_pushvalue(gL, -5);
lua_pushvalue(gL, -5);
lua_pushvalue(gL, -5);
lua_pushvalue(gL, -5);
if (lua_pcall(gL, 4, 1, 1)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
>>>>>>> srb2/next
lua_pop(gL, 1); lua_pop(gL, 1);
hookp->error = true;
continue;
} }
if (lua_toboolean(gL, -1))
hooked = true;
lua_pop(gL, 1);
}
lua_settop(gL, 0); lua_settop(gL, 0);
return hooked; return hooked;
}
} }
// Hook for hurt messages // Hook for hurt messages
@ -1911,7 +1892,6 @@ boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname)
return keepplaying; return keepplaying;
} }
<<<<<<< HEAD
// Hook for music changes // Hook for music changes
boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping, boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping,
UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms) UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms)
@ -1923,12 +1903,12 @@ boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boo
return false; return false;
lua_settop(gL, 0); lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
for (hookp = roothook; hookp; hookp = hookp->next) for (hookp = roothook; hookp; hookp = hookp->next)
if (hookp->type == hook_MusicChange) if (hookp->type == hook_MusicChange)
{ {
lua_pushfstring(gL, FMT_HOOKID, hookp->id); PushHook(gL, hookp);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_pushstring(gL, oldname); lua_pushstring(gL, oldname);
lua_pushstring(gL, newname); lua_pushstring(gL, newname);
lua_pushinteger(gL, *mflags); lua_pushinteger(gL, *mflags);
@ -1936,7 +1916,7 @@ boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boo
lua_pushinteger(gL, *position); lua_pushinteger(gL, *position);
lua_pushinteger(gL, *prefadems); lua_pushinteger(gL, *prefadems);
lua_pushinteger(gL, *fadeinms); lua_pushinteger(gL, *fadeinms);
if (lua_pcall(gL, 7, 6, 0)) { if (lua_pcall(gL, 7, 6, 1)) {
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL,-1)); CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL,-1));
lua_pop(gL, 1); lua_pop(gL, 1);
continue; continue;
@ -1963,7 +1943,7 @@ boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boo
if (lua_isboolean(gL, -1)) if (lua_isboolean(gL, -1))
*fadeinms = lua_tonumber(gL, -1); *fadeinms = lua_tonumber(gL, -1);
lua_pop(gL, 6); lua_pop(gL, 7); // Pop returned values and error handler
} }
lua_settop(gL, 0); lua_settop(gL, 0);