mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-26 12:21:19 +00:00
Reimplement the MusicChange hook
why the fuck was this removed
This commit is contained in:
parent
9395a0f5fc
commit
4d477d1aed
3 changed files with 75 additions and 0 deletions
|
@ -44,6 +44,9 @@ enum hook {
|
||||||
hook_HurtMsg,
|
hook_HurtMsg,
|
||||||
hook_PlayerSpawn,
|
hook_PlayerSpawn,
|
||||||
hook_PlayerQuit,
|
hook_PlayerQuit,
|
||||||
|
#ifdef HAVE_LUA_MUSICPLUS
|
||||||
|
hook_MusicChange,
|
||||||
|
#endif
|
||||||
hook_ShouldSpin, //SRB2KART
|
hook_ShouldSpin, //SRB2KART
|
||||||
hook_ShouldExplode, //SRB2KART
|
hook_ShouldExplode, //SRB2KART
|
||||||
hook_ShouldSquish, //SRB2KART
|
hook_ShouldSquish, //SRB2KART
|
||||||
|
@ -90,6 +93,10 @@ boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg, int mute);
|
||||||
boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source); // Hook for hurt messages
|
boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source); // Hook for hurt messages
|
||||||
#define LUAh_PlayerSpawn(player) LUAh_PlayerHook(player, hook_PlayerSpawn) // Hook for G_SpawnPlayer
|
#define LUAh_PlayerSpawn(player) LUAh_PlayerHook(player, hook_PlayerSpawn) // Hook for G_SpawnPlayer
|
||||||
void LUAh_PlayerQuit(player_t *plr, int reason); // Hook for player quitting
|
void LUAh_PlayerQuit(player_t *plr, int reason); // Hook for player quitting
|
||||||
|
#ifdef HAVE_LUA_MUSICPLUS
|
||||||
|
boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping,
|
||||||
|
UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms); // Hook for music changes
|
||||||
|
#endif
|
||||||
|
|
||||||
UINT8 LUAh_ShouldSpin(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Should player be spun out?
|
UINT8 LUAh_ShouldSpin(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Should player be spun out?
|
||||||
UINT8 LUAh_ShouldExplode(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Should player be exploded?
|
UINT8 LUAh_ShouldExplode(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Should player be exploded?
|
||||||
|
|
|
@ -55,6 +55,9 @@ const char *const hookNames[hook_MAX+1] = {
|
||||||
"HurtMsg",
|
"HurtMsg",
|
||||||
"PlayerSpawn",
|
"PlayerSpawn",
|
||||||
"PlayerQuit",
|
"PlayerQuit",
|
||||||
|
#ifdef HAVE_LUA_MUSICPLUS
|
||||||
|
"MusicChange",
|
||||||
|
#endif
|
||||||
"ShouldSpin",
|
"ShouldSpin",
|
||||||
"ShouldExplode",
|
"ShouldExplode",
|
||||||
"ShouldSquish",
|
"ShouldSquish",
|
||||||
|
@ -1213,6 +1216,69 @@ void LUAh_PlayerQuit(player_t *plr, int reason)
|
||||||
lua_settop(gL, 0);
|
lua_settop(gL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_LUA_MUSICPLUS
|
||||||
|
|
||||||
|
// Hook for music changes
|
||||||
|
boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping,
|
||||||
|
UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms)
|
||||||
|
{
|
||||||
|
hook_p hookp;
|
||||||
|
boolean hooked = false;
|
||||||
|
|
||||||
|
if (!gL || !(hooksAvailable[hook_MusicChange/8] & (1<<(hook_MusicChange%8))))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
lua_settop(gL, 0);
|
||||||
|
|
||||||
|
for (hookp = roothook; hookp; hookp = hookp->next)
|
||||||
|
if (hookp->type == hook_MusicChange)
|
||||||
|
{
|
||||||
|
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
|
||||||
|
lua_gettable(gL, LUA_REGISTRYINDEX);
|
||||||
|
lua_pushstring(gL, oldname);
|
||||||
|
lua_pushstring(gL, newname);
|
||||||
|
lua_pushinteger(gL, *mflags);
|
||||||
|
lua_pushboolean(gL, *looping);
|
||||||
|
lua_pushinteger(gL, *position);
|
||||||
|
lua_pushinteger(gL, *prefadems);
|
||||||
|
lua_pushinteger(gL, *fadeinms);
|
||||||
|
if (lua_pcall(gL, 7, 6, 0)) {
|
||||||
|
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL,-1));
|
||||||
|
lua_pop(gL, 1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// output 1: true, false, or string musicname override
|
||||||
|
if (lua_isboolean(gL, -6) && lua_toboolean(gL, -6))
|
||||||
|
hooked = true;
|
||||||
|
else if (lua_isstring(gL, -6))
|
||||||
|
strncpy(newname, lua_tostring(gL, -6), 7);
|
||||||
|
// output 2: mflags override
|
||||||
|
if (lua_isnumber(gL, -5))
|
||||||
|
*mflags = lua_tonumber(gL, -5);
|
||||||
|
// output 3: looping override
|
||||||
|
if (lua_isboolean(gL, -4))
|
||||||
|
*looping = lua_toboolean(gL, -4);
|
||||||
|
// output 4: position override
|
||||||
|
if (lua_isboolean(gL, -3))
|
||||||
|
*position = lua_tonumber(gL, -3);
|
||||||
|
// output 5: prefadems override
|
||||||
|
if (lua_isboolean(gL, -2))
|
||||||
|
*prefadems = lua_tonumber(gL, -2);
|
||||||
|
// output 6: fadeinms override
|
||||||
|
if (lua_isboolean(gL, -1))
|
||||||
|
*fadeinms = lua_tonumber(gL, -1);
|
||||||
|
|
||||||
|
lua_pop(gL, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
lua_settop(gL, 0);
|
||||||
|
newname[6] = 0;
|
||||||
|
return hooked;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// Hook for K_SpinPlayer. Determines if yes or no we should get damaged reguardless of circumstances.
|
// Hook for K_SpinPlayer. Determines if yes or no we should get damaged reguardless of circumstances.
|
||||||
UINT8 LUAh_ShouldSpin(player_t *player, mobj_t *inflictor, mobj_t *source)
|
UINT8 LUAh_ShouldSpin(player_t *player, mobj_t *inflictor, mobj_t *source)
|
||||||
{
|
{
|
||||||
|
|
|
@ -98,4 +98,6 @@ void COM_Lua_f(void);
|
||||||
}\
|
}\
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define HAVE_LUA_MUSICPLUS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue