Fix conflicts 522467a88

This commit is contained in:
James R 2022-09-05 10:54:38 -07:00
parent b4d1fade5f
commit 37c3a55dda
23 changed files with 86 additions and 205 deletions

View file

@ -2348,14 +2348,14 @@ void CL_RemovePlayer(INT32 playernum, kickreason_t reason)
K_CalculateBattleWanted(); K_CalculateBattleWanted();
LUAh_PlayerQuit(&players[playernum], reason); // Lua hook for player quitting LUA_HookPlayerQuit(&players[playernum], reason); // Lua hook for player quitting
// don't look through someone's view who isn't there // don't look through someone's view who isn't there
if (playernum == displayplayers[0] && !demo.playback) if (playernum == displayplayers[0] && !demo.playback)
{ {
// Call ViewpointSwitch hooks here. // Call ViewpointSwitch hooks here.
// The viewpoint was forcibly changed. // The viewpoint was forcibly changed.
LUAh_ViewpointSwitch(&players[consoleplayer], &players[consoleplayer], true); LUA_HookViewpointSwitch(&players[consoleplayer], &players[consoleplayer], true);
displayplayers[0] = consoleplayer; displayplayers[0] = consoleplayer;
} }
@ -2859,7 +2859,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
if (playernode[pnum] == playernode[consoleplayer]) if (playernode[pnum] == playernode[consoleplayer])
{ {
LUAh_GameQuit(false); LUA_HookBool(false, HOOK(GameQuit));
#ifdef DUMPCONSISTENCY #ifdef DUMPCONSISTENCY
if (msg == KICK_MSG_CON_FAIL) SV_SavedGame(); if (msg == KICK_MSG_CON_FAIL) SV_SavedGame();
#endif #endif
@ -3377,7 +3377,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
if (server && multiplayer && motd[0] != '\0') if (server && multiplayer && motd[0] != '\0')
COM_BufAddText(va("sayto %d %s\n", newplayernum, motd)); COM_BufAddText(va("sayto %d %s\n", newplayernum, motd));
LUAh_PlayerJoin(newplayernum); LUA_HookInt(newplayernum, HOOK(PlayerJoin));
#ifdef HAVE_DISCORDRPC #ifdef HAVE_DISCORDRPC
DRPC_UpdatePresence(); DRPC_UpdatePresence();
@ -3458,7 +3458,7 @@ static void Got_AddBot(UINT8 **p, INT32 playernum)
HU_AddChatText(va("\x82*Bot %d has been added to the game", newplayernum+1), false); HU_AddChatText(va("\x82*Bot %d has been added to the game", newplayernum+1), false);
} }
LUAh_PlayerJoin(newplayernum); LUA_HookInt(newplayernum, HOOK(PlayerJoin));
} }
static boolean SV_AddWaitingPlayers(SINT8 node, const char *name, const char *name2, const char *name3, const char *name4) static boolean SV_AddWaitingPlayers(SINT8 node, const char *name, const char *name2, const char *name3, const char *name4)
@ -3803,7 +3803,7 @@ static void HandleConnect(SINT8 node)
static void HandleShutdown(SINT8 node) static void HandleShutdown(SINT8 node)
{ {
(void)node; (void)node;
LUAh_GameQuit(false); LUA_HookBool(false, HOOK(GameQuit));
D_QuitNetGame(); D_QuitNetGame();
CL_Reset(); CL_Reset();
D_StartTitle(); D_StartTitle();
@ -3818,7 +3818,7 @@ static void HandleShutdown(SINT8 node)
static void HandleTimeout(SINT8 node) static void HandleTimeout(SINT8 node)
{ {
(void)node; (void)node;
LUAh_GameQuit(false); LUA_HookBool(false, HOOK(GameQuit));
D_QuitNetGame(); D_QuitNetGame();
CL_Reset(); CL_Reset();
D_StartTitle(); D_StartTitle();

View file

@ -3412,7 +3412,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum)
} }
// Don't switch team, just go away, please, go awaayyyy, aaauuauugghhhghgh // Don't switch team, just go away, please, go awaayyyy, aaauuauugghhhghgh
if (!LUAh_TeamSwitch(&players[playernum], NetPacket.packet.newteam, players[playernum].spectator, NetPacket.packet.autobalance, NetPacket.packet.scrambled)) if (!LUA_HookTeamSwitch(&players[playernum], NetPacket.packet.newteam, players[playernum].spectator, NetPacket.packet.autobalance, NetPacket.packet.scrambled))
return; return;
//Make sure that the right team number is sent. Keep in mind that normal clients cannot change to certain teams in certain gametypes. //Make sure that the right team number is sent. Keep in mind that normal clients cannot change to certain teams in certain gametypes.
@ -3508,7 +3508,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum)
{ {
if (localplayertable[i] == playernum) if (localplayertable[i] == playernum)
{ {
LUAh_ViewpointSwitch(players+playernum, players+playernum, true); LUA_HookViewpointSwitch(players+playernum, players+playernum, true);
displayplayers[i] = playernum; displayplayers[i] = playernum;
break; break;
} }
@ -4428,7 +4428,7 @@ static void Command_Playintro_f(void)
*/ */
FUNCNORETURN static ATTRNORETURN void Command_Quit_f(void) FUNCNORETURN static ATTRNORETURN void Command_Quit_f(void)
{ {
LUAh_GameQuit(true); LUA_HookBool(true, HOOK(GameQuit));
I_Quit(); I_Quit();
} }
@ -4992,7 +4992,7 @@ void Command_ExitGame_f(void)
{ {
INT32 i; INT32 i;
LUAh_GameQuit(false); LUA_HookBool(false, HOOK(GameQuit));
D_QuitNetGame(); D_QuitNetGame();
CL_Reset(); CL_Reset();

View file

@ -368,6 +368,8 @@ typedef UINT32 tic_t;
#define UINT2RGBA(a) (UINT32)((a&0xff)<<24)|((a&0xff00)<<8)|((a&0xff0000)>>8)|(((UINT32)a&0xff000000)>>24) #define UINT2RGBA(a) (UINT32)((a&0xff)<<24)|((a&0xff00)<<8)|((a&0xff0000)>>8)|(((UINT32)a&0xff000000)>>24)
#endif #endif
#define TOSTR(x) #x
/* preprocessor dumb and needs second macro to expand input */ /* preprocessor dumb and needs second macro to expand input */
#define WSTRING2(s) L ## s #define WSTRING2(s) L ## s
#define WSTRING(s) WSTRING2 (s) #define WSTRING(s) WSTRING2 (s)

View file

@ -41,6 +41,7 @@
#include "fastcmp.h" #include "fastcmp.h"
#include "lua_hud.h" #include "lua_hud.h"
#include "lua_hook.h"
// Stage of animation: // Stage of animation:
// 0 = text, 1 = art screen // 0 = text, 1 = art screen
@ -2118,7 +2119,7 @@ luahook:
if (renderisnewtic) if (renderisnewtic)
{ {
LUA_HUD_ClearDrawList(luahuddrawlist_title); LUA_HUD_ClearDrawList(luahuddrawlist_title);
LUAh_TitleHUD(luahuddrawlist_title); LUA_HookHUD(luahuddrawlist_title, HUD_HOOK(title));
} }
LUA_HUD_DrawList(luahuddrawlist_title); LUA_HUD_DrawList(luahuddrawlist_title);
} }

View file

@ -1223,7 +1223,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
*/ */
if (addedtogame && gamestate == GS_LEVEL) if (addedtogame && gamestate == GS_LEVEL)
{ {
LUAh_PlayerCmd(player, cmd); LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd));
// Send leveltime when this tic was generated to the server for control lag calculations. // Send leveltime when this tic was generated to the server for control lag calculations.
// Only do this when in a level. Also do this after the hook, so that it can't overwrite this. // Only do this when in a level. Also do this after the hook, so that it can't overwrite this.
@ -1253,7 +1253,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
{ {
// Call ViewpointSwitch hooks here. // Call ViewpointSwitch hooks here.
// The viewpoint was forcibly changed. // The viewpoint was forcibly changed.
LUAh_ViewpointSwitch(player, &players[consoleplayer], true); LUA_HookViewpointSwitch(player, &players[consoleplayer], true);
displayplayers[0] = consoleplayer; displayplayers[0] = consoleplayer;
} }
} }
@ -2532,7 +2532,7 @@ void G_SpawnPlayer(INT32 playernum)
P_SpawnPlayer(playernum); P_SpawnPlayer(playernum);
G_MovePlayerToSpawnOrStarpost(playernum); G_MovePlayerToSpawnOrStarpost(playernum);
LUAh_PlayerSpawn(&players[playernum]); // Lua hook for player spawning :) LUA_HookPlayer(&players[playernum], HOOK(PlayerSpawn)); // Lua hook for player spawning :)
} }
void G_MovePlayerToSpawnOrStarpost(INT32 playernum) void G_MovePlayerToSpawnOrStarpost(INT32 playernum)
@ -4666,7 +4666,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool
F_StartCustomCutscene(mapheaderinfo[gamemap-1]->precutscenenum-1, true, resetplayer); F_StartCustomCutscene(mapheaderinfo[gamemap-1]->precutscenenum-1, true, resetplayer);
else else
{ {
LUAh_MapChange(gamemap); LUA_HookInt(HOOK(MapChange), gamemap);
G_DoLoadLevel(resetplayer); G_DoLoadLevel(resetplayer);
} }

View file

@ -694,7 +694,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
// run the lua hook even if we were supposed to eat the msg, netgame consistency goes first. // run the lua hook even if we were supposed to eat the msg, netgame consistency goes first.
if (LUAh_PlayerMsg(playernum, target, flags, msg, spam_eatmsg)) if (LUA_HookPlayerMsg(playernum, target, flags, msg, spam_eatmsg))
return; return;
if (spam_eatmsg) if (spam_eatmsg)
@ -2123,7 +2123,7 @@ void HU_Drawer(void)
if (renderisnewtic) if (renderisnewtic)
{ {
LUA_HUD_ClearDrawList(luahuddrawlist_scores); LUA_HUD_ClearDrawList(luahuddrawlist_scores);
LUAh_ScoresHUD(luahuddrawlist_scores); LUA_HookHUD(luahuddrawlist_scores, HUD_HOOK(scores));
} }
LUA_HUD_DrawList(luahuddrawlist_scores); LUA_HUD_DrawList(luahuddrawlist_scores);
} }

View file

@ -1247,7 +1247,7 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd)
} }
// Complete override of all ticcmd functionality // Complete override of all ticcmd functionality
if (LUAh_BotTiccmd(player, cmd) == true) if (LUA_HookTiccmd(player, cmd, HOOK(BotTiccmd)) == true)
{ {
return; return;
} }

View file

@ -69,15 +69,11 @@ automatically.
X (SeenPlayer),/* MT_NAMECHECK */\ X (SeenPlayer),/* MT_NAMECHECK */\
X (PlayerThink),/* P_PlayerThink */\ X (PlayerThink),/* P_PlayerThink */\
X (GameQuit),\ X (GameQuit),\
X (PlayerCmd),/* building the player's ticcmd struct (Ported from SRB2Kart) */\ X (PlayerCmd),/* building the player's ticcmd struct */\
X (MusicChange),\ X (MusicChange),\
X (PlayerHeight),/* override player height */\ X (VoteThinker),/* Y_VoteTicker */\
X (PlayerCanEnterSpinGaps),\
X (KeyDown),\
X (KeyUp),\
#define STRING_HOOK_LIST(X) \ #define STRING_HOOK_LIST(X) \
X (BotAI),/* B_BuildTailsTiccmd by skin name */\
X (LinedefExecute),\ X (LinedefExecute),\
X (ShouldJingleContinue),/* should jingle of the given music continue playing */\ X (ShouldJingleContinue),/* should jingle of the given music continue playing */\
@ -115,6 +111,7 @@ ENUM (STRING_HOOK);
//#define LUA_HUDHOOK(type) LUA_HookHUD(HUD_HOOK(type)) //#define LUA_HUDHOOK(type) LUA_HookHUD(HUD_HOOK(type))
extern boolean hook_cmd_running; extern boolean hook_cmd_running;
extern int hook_defrosting;
void LUA_HookVoid(int hook); void LUA_HookVoid(int hook);
void LUA_HookHUD(huddrawlist_h, int hook); void LUA_HookHUD(huddrawlist_h, int hook);
@ -134,9 +131,8 @@ int LUA_HookShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT
int LUA_HookMobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype); int LUA_HookMobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype);
int LUA_HookMobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damagetype); int LUA_HookMobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damagetype);
int LUA_HookMobjMoveBlocked(mobj_t *, mobj_t *, line_t *); int LUA_HookMobjMoveBlocked(mobj_t *, mobj_t *, line_t *);
int LUA_HookBotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd);
void LUA_HookLinedefExecute(line_t *, mobj_t *, sector_t *); void LUA_HookLinedefExecute(line_t *, mobj_t *, sector_t *);
int LUA_HookPlayerMsg(int source, int target, int flags, char *msg); int LUA_HookPlayerMsg(int source, int target, int flags, char *msg, int mute);
int LUA_HookHurtMsg(player_t *, mobj_t *inflictor, mobj_t *source, UINT8 damagetype); int LUA_HookHurtMsg(player_t *, mobj_t *inflictor, mobj_t *source, UINT8 damagetype);
int LUA_HookMapThingSpawn(mobj_t *, mapthing_t *); int LUA_HookMapThingSpawn(mobj_t *, mapthing_t *);
int LUA_HookFollowMobj(player_t *, mobj_t *); int LUA_HookFollowMobj(player_t *, mobj_t *);
@ -146,7 +142,4 @@ int LUA_HookTeamSwitch(player_t *, int newteam, boolean fromspectators, boolean
int LUA_HookViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean forced); int LUA_HookViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean forced);
int LUA_HookSeenPlayer(player_t *player, player_t *seenfriend); int LUA_HookSeenPlayer(player_t *player, player_t *seenfriend);
int LUA_HookShouldJingleContinue(player_t *, const char *musname); int LUA_HookShouldJingleContinue(player_t *, const char *musname);
int LUA_HookPlayerCmd(player_t *, ticcmd_t *);
int LUA_HookMusicChange(const char *oldname, struct MusicChange *); int LUA_HookMusicChange(const char *oldname, struct MusicChange *);
fixed_t LUA_HookPlayerHeight(player_t *player);
int LUA_HookPlayerCanEnterSpinGaps(player_t *player);

View file

@ -123,7 +123,6 @@ static void add_string_hook(lua_State *L, int type)
switch (type) switch (type)
{ {
case STRING_HOOK(BotAI):
case STRING_HOOK(ShouldJingleContinue): case STRING_HOOK(ShouldJingleContinue):
if (lua_isstring(L, 3)) if (lua_isstring(L, 3))
{ // lowercase copy { // lowercase copy
@ -630,22 +629,7 @@ int LUA_HookTiccmd(player_t *player, ticcmd_t *cmd, int hook_type)
return hook.status; return hook.status;
} }
<<<<<<< Updated upstream
int LUA_HookKey(event_t *event, int hook_type)
{
Hook_State hook;
if (prepare_hook(&hook, false, hook_type))
{
LUA_PushUserdata(gL, event, META_KEYEVENT);
call_hooks(&hook, 1, res_true);
}
return hook.status;
}
void LUA_HookHUD(int hook_type, huddrawlist_h list)
=======
void LUA_HookHUD(huddrawlist_h list, int hook_type) void LUA_HookHUD(huddrawlist_h list, int hook_type)
>>>>>>> Stashed changes
{ {
const hook_t * map = &hudHookIds[hook_type]; const hook_t * map = &hudHookIds[hook_type];
Hook_State hook; Hook_State hook;
@ -789,82 +773,6 @@ int LUA_HookMobjMoveBlocked(mobj_t *t1, mobj_t *t2, line_t *line)
return hook.status; return hook.status;
} }
typedef struct {
mobj_t * tails;
ticcmd_t * cmd;
} BotAI_State;
static boolean checkbotkey(const char *field)
{
return lua_toboolean(gL, -1) && strcmp(lua_tostring(gL, -2), field) == 0;
}
static void res_botai(Hook_State *hook)
{
BotAI_State *botai = hook->userdata;
int k[8];
int fields = 0;
// This turns forward, backward, left, right, jump, and spin into a proper ticcmd for tails.
if (lua_istable(gL, -8)) {
lua_pushnil(gL); // key
while (lua_next(gL, -9)) {
#define CHECK(n, f) (checkbotkey(f) ? (k[(n)-1] = 1) : 0)
if (
CHECK(1, "forward") || CHECK(2, "backward") ||
CHECK(3, "left") || CHECK(4, "right") ||
CHECK(5, "strafeleft") || CHECK(6, "straferight") ||
CHECK(7, "jump") || CHECK(8, "spin")
){
if (8 <= ++fields)
{
lua_pop(gL, 2); // pop key and value
break;
}
}
lua_pop(gL, 1); // pop value
#undef CHECK
}
} else {
while (fields < 8)
{
k[fields] = lua_toboolean(gL, -8 + fields);
fields++;
}
}
B_KeysToTiccmd(botai->tails, botai->cmd,
k[0],k[1],k[2],k[3],k[4],k[5],k[6],k[7]);
hook->status = true;
}
int LUA_HookBotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
{
const char *skin = ((skin_t *)tails->skin)->name;
Hook_State hook;
BotAI_State botai;
if (prepare_string_hook(&hook, false, STRING_HOOK(BotAI), skin))
{
LUA_PushUserdata(gL, sonic, META_MOBJ);
LUA_PushUserdata(gL, tails, META_MOBJ);
botai.tails = tails;
botai.cmd = cmd;
hook.userdata = &botai;
call_hooks(&hook, 8, res_botai);
}
return hook.status;
}
void LUA_HookLinedefExecute(line_t *line, mobj_t *mo, sector_t *sector) void LUA_HookLinedefExecute(line_t *line, mobj_t *mo, sector_t *sector)
{ {
Hook_State hook; Hook_State hook;
@ -878,7 +786,7 @@ void LUA_HookLinedefExecute(line_t *line, mobj_t *mo, sector_t *sector)
} }
} }
int LUA_HookPlayerMsg(int source, int target, int flags, char *msg) int LUA_HookPlayerMsg(int source, int target, int flags, char *msg, int mute)
{ {
Hook_State hook; Hook_State hook;
if (prepare_hook(&hook, false, HOOK(PlayerMsg))) if (prepare_hook(&hook, false, HOOK(PlayerMsg)))
@ -898,6 +806,8 @@ int LUA_HookPlayerMsg(int source, int target, int flags, char *msg)
LUA_PushUserdata(gL, &players[target-1], META_PLAYER); // target LUA_PushUserdata(gL, &players[target-1], META_PLAYER); // target
} }
lua_pushstring(gL, msg); // msg lua_pushstring(gL, msg); // msg
lua_pushboolean(gL, mute); // the message was supposed to be eaten by spamprotecc.
call_hooks(&hook, 1, res_true); call_hooks(&hook, 1, res_true);
} }
return hook.status; return hook.status;
@ -1143,38 +1053,3 @@ int LUA_HookMusicChange(const char *oldname, struct MusicChange *param)
return hook.status; return hook.status;
} }
static void res_playerheight(Hook_State *hook)
{
if (!lua_isnil(gL, -1))
{
fixed_t returnedheight = lua_tonumber(gL, -1);
// 0 height has... strange results, but it's not problematic like negative heights are.
// when an object's height is set to a negative number directly with lua, it's forced to 0 instead.
// here, I think it's better to ignore negatives so that they don't replace any results of previous hooks!
if (returnedheight >= 0)
hook->status = returnedheight;
}
}
fixed_t LUA_HookPlayerHeight(player_t *player)
{
Hook_State hook;
if (prepare_hook(&hook, -1, HOOK(PlayerHeight)))
{
LUA_PushUserdata(gL, player, META_PLAYER);
call_hooks(&hook, 1, res_playerheight);
}
return hook.status;
}
int LUA_HookPlayerCanEnterSpinGaps(player_t *player)
{
Hook_State hook;
if (prepare_hook(&hook, 0, HOOK(PlayerCanEnterSpinGaps)))
{
LUA_PushUserdata(gL, player, META_PLAYER);
call_hooks(&hook, 1, res_force);
}
return hook.status;
}

View file

@ -1687,7 +1687,7 @@ void LUA_Archive(UINT8 **p)
WRITEUINT32(*p, UINT32_MAX); // end of mobjs marker, replaces mobjnum. WRITEUINT32(*p, UINT32_MAX); // end of mobjs marker, replaces mobjnum.
LUAh_NetArchiveHook(NetArchive); // call the NetArchive hook in archive mode LUA_HookNetArchive(NetArchive); // call the NetArchive hook in archive mode
} }
ArchiveTables(p); ArchiveTables(p);
@ -1726,7 +1726,7 @@ void LUA_UnArchive(UINT8 **p)
} }
} while(mobjnum != UINT32_MAX); // repeat until end of mobjs marker. } while(mobjnum != UINT32_MAX); // repeat until end of mobjs marker.
LUAh_NetArchiveHook(NetUnArchive); // call the NetArchive hook in unarchive mode LUA_HookNetArchive(NetUnArchive); // call the NetArchive hook in unarchive mode
} }
UnArchiveTables(p); UnArchiveTables(p);

View file

@ -63,7 +63,7 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum); // lua_consolelib.c
void LUA_CVarChanged(void *cvar); // lua_consolelib.c void LUA_CVarChanged(void *cvar); // lua_consolelib.c
int Lua_optoption(lua_State *L, int narg, int Lua_optoption(lua_State *L, int narg,
const char *def, const char *const lst[]); const char *def, const char *const lst[]);
void LUAh_NetArchiveHook(lua_CFunction archFunc); void LUA_HookNetArchive(lua_CFunction archFunc);
void LUA_PushTaggableObjectArray void LUA_PushTaggableObjectArray
( lua_State *L, ( lua_State *L,

View file

@ -3495,7 +3495,7 @@ void A_BossDeath(mobj_t *mo)
} }
bossjustdie: bossjustdie:
if (LUAh_BossDeath(mo)) if (LUA_HookMobj(mo, MOBJ_HOOK(BossDeath)))
return; return;
else if (P_MobjWasRemoved(mo)) else if (P_MobjWasRemoved(mo))
return; return;

View file

@ -219,7 +219,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
if (special->flags & (MF_ENEMY|MF_BOSS) && special->flags2 & MF2_FRET) if (special->flags & (MF_ENEMY|MF_BOSS) && special->flags2 & MF2_FRET)
return; return;
if (LUAh_TouchSpecial(special, toucher) || P_MobjWasRemoved(special)) if (LUA_HookTouchSpecial(special, toucher) || P_MobjWasRemoved(special))
return; return;
if ((special->flags & (MF_ENEMY|MF_BOSS)) && !(special->flags & MF_MISSILE)) if ((special->flags & (MF_ENEMY|MF_BOSS)) && !(special->flags & MF_MISSILE))
@ -969,7 +969,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
target->shadowscale = 0; target->shadowscale = 0;
} }
if (LUAh_MobjDeath(target, inflictor, source, damagetype) || P_MobjWasRemoved(target)) if (LUA_HookMobjDeath(target, inflictor, source, damagetype) || P_MobjWasRemoved(target))
return; return;
//K_SetHitLagForObjects(target, inflictor, MAXHITLAGTICS, true); //K_SetHitLagForObjects(target, inflictor, MAXHITLAGTICS, true);
@ -1855,7 +1855,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
// Everything above here can't be forced. // Everything above here can't be forced.
if (!metalrecording) if (!metalrecording)
{ {
UINT8 shouldForce = LUAh_ShouldDamage(target, inflictor, source, damage, damagetype); UINT8 shouldForce = LUA_HookShouldDamage(target, inflictor, source, damage, damagetype);
if (P_MobjWasRemoved(target)) if (P_MobjWasRemoved(target))
return (shouldForce == 1); // mobj was removed return (shouldForce == 1); // mobj was removed
if (shouldForce == 1) if (shouldForce == 1)
@ -1881,7 +1881,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
if (!force && target->flags2 & MF2_FRET) // Currently flashing from being hit if (!force && target->flags2 & MF2_FRET) // Currently flashing from being hit
return false; return false;
if (LUAh_MobjDamage(target, inflictor, source, damage, damagetype) || P_MobjWasRemoved(target)) if (LUA_HookMobjDamage(target, inflictor, source, damage, damagetype) || P_MobjWasRemoved(target))
return true; return true;
if (target->health > 1) if (target->health > 1)
@ -1911,7 +1911,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
if (!P_KillPlayer(player, inflictor, source, damagetype)) if (!P_KillPlayer(player, inflictor, source, damagetype))
return false; return false;
} }
else if (LUAh_MobjDamage(target, inflictor, source, damage, damagetype)) else if (LUA_HookMobjDamage(target, inflictor, source, damage, damagetype))
{ {
return true; return true;
} }

View file

@ -656,7 +656,7 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing)
} }
{ {
UINT8 shouldCollide = LUAh_MobjCollide(thing, tmthing); // checks hook for thing's type UINT8 shouldCollide = LUA_Hook2Mobj(thing, tmthing, MOBJ_HOOK(MobjCollide)); // checks hook for thing's type
if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing)) if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing))
return BMIT_CONTINUE; // one of them was removed??? return BMIT_CONTINUE; // one of them was removed???
if (shouldCollide == 1) if (shouldCollide == 1)
@ -664,7 +664,7 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing)
else if (shouldCollide == 2) else if (shouldCollide == 2)
return BMIT_CONTINUE; // force no collide return BMIT_CONTINUE; // force no collide
shouldCollide = LUAh_MobjMoveCollide(tmthing, thing); // checks hook for tmthing's type shouldCollide = LUA_Hook2Mobj(tmthing, thing, MOBJ_HOOK(MobjMoveCollide)); // checks hook for tmthing's type
if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing)) if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing))
return BMIT_CONTINUE; // one of them was removed??? return BMIT_CONTINUE; // one of them was removed???
if (shouldCollide == 1) if (shouldCollide == 1)
@ -1640,7 +1640,7 @@ static BlockItReturn_t PIT_CheckLine(line_t *ld)
blockingline = ld; blockingline = ld;
{ {
UINT8 shouldCollide = LUAh_MobjLineCollide(tmthing, blockingline); // checks hook for thing's type UINT8 shouldCollide = LUA_HookMobjLineCollide(tmthing, blockingline); // checks hook for thing's type
if (P_MobjWasRemoved(tmthing)) if (P_MobjWasRemoved(tmthing))
return BMIT_CONTINUE; // one of them was removed??? return BMIT_CONTINUE; // one of them was removed???
if (shouldCollide == 1) if (shouldCollide == 1)

View file

@ -1568,7 +1568,7 @@ void P_XYMovement(mobj_t *mo)
// blocked move // blocked move
moved = false; moved = false;
if (LUAh_MobjMoveBlocked(mo)) if (LUA_HookMobjMoveBlocked(mo, tmhitthing, blockingline))
{ {
if (P_MobjWasRemoved(mo)) if (P_MobjWasRemoved(mo))
return; return;
@ -3963,7 +3963,7 @@ static void P_RingThinker(mobj_t *mobj)
if (!mobj->fuse) if (!mobj->fuse)
{ {
if (!LUAh_MobjFuse(mobj)) if (!LUA_HookMobj(mobj, MOBJ_HOOK(MobjFuse)))
{ {
mobj->renderflags &= ~RF_DONTDRAW; mobj->renderflags &= ~RF_DONTDRAW;
spark = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_SIGNSPARKLE); // Spawn a fancy sparkle spark = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_SIGNSPARKLE); // Spawn a fancy sparkle
@ -5343,7 +5343,7 @@ static boolean P_ParticleGenSceneryThink(mobj_t *mobj)
static void P_MobjSceneryThink(mobj_t *mobj) static void P_MobjSceneryThink(mobj_t *mobj)
{ {
if (LUAh_MobjThinker(mobj)) if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjThinker)))
return; return;
if (P_MobjWasRemoved(mobj)) if (P_MobjWasRemoved(mobj))
return; return;
@ -6205,7 +6205,7 @@ static void P_MobjSceneryThink(mobj_t *mobj)
mobj->fuse--; mobj->fuse--;
if (!mobj->fuse) if (!mobj->fuse)
{ {
if (!LUAh_MobjFuse(mobj)) if (!LUA_HookMobj(mobj, MOBJ_HOOK(MobjFuse)))
P_RemoveMobj(mobj); P_RemoveMobj(mobj);
return; return;
} }
@ -6225,7 +6225,7 @@ static boolean P_MobjPushableThink(mobj_t *mobj)
static boolean P_MobjBossThink(mobj_t *mobj) static boolean P_MobjBossThink(mobj_t *mobj)
{ {
if (LUAh_BossThinker(mobj)) if (LUA_HookMobj(mobj, MOBJ_HOOK(BossThinker)))
{ {
if (P_MobjWasRemoved(mobj)) if (P_MobjWasRemoved(mobj))
return false; return false;
@ -9147,7 +9147,7 @@ static boolean P_FuseThink(mobj_t *mobj)
if (mobj->fuse) if (mobj->fuse)
return true; return true;
if (LUAh_MobjFuse(mobj) || P_MobjWasRemoved(mobj)) if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjFuse)) || P_MobjWasRemoved(mobj))
; ;
else if (mobj->info->flags & MF_MONITOR) else if (mobj->info->flags & MF_MONITOR)
{ {
@ -9379,13 +9379,13 @@ void P_MobjThinker(mobj_t *mobj)
// Check for a Lua thinker first // Check for a Lua thinker first
if (!mobj->player) if (!mobj->player)
{ {
if (LUAh_MobjThinker(mobj) || P_MobjWasRemoved(mobj)) if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjThinker)) || P_MobjWasRemoved(mobj))
return; return;
} }
else if (!mobj->player->spectator) else if (!mobj->player->spectator)
{ {
// You cannot short-circuit the player thinker like you can other thinkers. // You cannot short-circuit the player thinker like you can other thinkers.
LUAh_MobjThinker(mobj); LUA_HookMobj(mobj, MOBJ_HOOK(MobjThinker));
if (P_MobjWasRemoved(mobj)) if (P_MobjWasRemoved(mobj))
return; return;
} }
@ -9977,7 +9977,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
// DANGER! This can cause P_SpawnMobj to return NULL! // DANGER! This can cause P_SpawnMobj to return NULL!
// Avoid using P_RemoveMobj on the newly created mobj in "MobjSpawn" Lua hooks! // Avoid using P_RemoveMobj on the newly created mobj in "MobjSpawn" Lua hooks!
if (LUAh_MobjSpawn(mobj)) if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjSpawn)))
{ {
if (P_MobjWasRemoved(mobj)) if (P_MobjWasRemoved(mobj))
return NULL; return NULL;
@ -10577,7 +10577,7 @@ void P_RemoveMobj(mobj_t *mobj)
return; // something already removing this mobj. return; // something already removing this mobj.
mobj->thinker.function.acp1 = (actionf_p1)P_RemoveThinkerDelayed; // shh. no recursing. mobj->thinker.function.acp1 = (actionf_p1)P_RemoveThinkerDelayed; // shh. no recursing.
LUAh_MobjRemoved(mobj); LUA_HookMobj(mobj, MOBJ_HOOK(MobjRemoved));
mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; // needed for P_UnsetThingPosition, etc. to work. mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; // needed for P_UnsetThingPosition, etc. to work.
// Rings only, please! // Rings only, please!
@ -12174,7 +12174,7 @@ static void P_SnapToFinishLine(mobj_t *mobj)
static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean *doangle) static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean *doangle)
{ {
boolean override = LUAh_MapThingSpawn(mobj, mthing); boolean override = LUA_HookMapThingSpawn(mobj, mthing);
if (P_MobjWasRemoved(mobj)) if (P_MobjWasRemoved(mobj))
return false; return false;

View file

@ -66,7 +66,7 @@
#include "md5.h" // map MD5 #include "md5.h" // map MD5
// for LUAh_MapLoad // for MapLoad hook
#include "lua_script.h" #include "lua_script.h"
#include "lua_hook.h" #include "lua_hook.h"
@ -4485,7 +4485,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
} }
P_PreTicker(2); P_PreTicker(2);
P_MapStart(); // just in case MapLoad modifies tmthing P_MapStart(); // just in case MapLoad modifies tmthing
LUAh_MapLoad(); LUA_HookInt(gamemap, HOOK(MapLoad));
P_MapEnd(); // just in case MapLoad modifies tmthing P_MapEnd(); // just in case MapLoad modifies tmthing
} }

View file

@ -36,7 +36,7 @@
#include "v_video.h" // V_ALLOWLOWERCASE #include "v_video.h" // V_ALLOWLOWERCASE
#include "m_misc.h" #include "m_misc.h"
#include "m_cond.h" //unlock triggers #include "m_cond.h" //unlock triggers
#include "lua_hook.h" // LUAh_LinedefExecute #include "lua_hook.h" // LUA_HookLinedefExecute
#include "f_finale.h" // control text prompt #include "f_finale.h" // control text prompt
#include "r_skins.h" // skins #include "r_skins.h" // skins
@ -3028,7 +3028,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
case 443: // Calls a named Lua function case 443: // Calls a named Lua function
if (line->stringargs[0]) if (line->stringargs[0])
LUAh_LinedefExecute(line, mo, callsec); LUA_HookLinedefExecute(line, mo, callsec);
else else
CONS_Alert(CONS_WARNING, "Linedef %s is missing the hook name of the Lua function to call! (This should be given in arg0str)\n", sizeu1(line-lines)); CONS_Alert(CONS_WARNING, "Linedef %s is missing the hook name of the Lua function to call! (This should be given in arg0str)\n", sizeu1(line-lines));
break; break;

View file

@ -581,7 +581,7 @@ void P_Ticker(boolean run)
ps_lua_mobjhooks = 0; ps_lua_mobjhooks = 0;
ps_checkposition_calls = 0; ps_checkposition_calls = 0;
LUAh_PreThinkFrame(); LUA_HOOK(PreThinkFrame);
ps_playerthink_time = I_GetPreciseTime(); ps_playerthink_time = I_GetPreciseTime();
@ -654,7 +654,7 @@ void P_Ticker(boolean run)
} }
ps_lua_thinkframe_time = I_GetPreciseTime(); ps_lua_thinkframe_time = I_GetPreciseTime();
LUAh_ThinkFrame(); LUA_HOOK(ThinkFrame);
ps_lua_thinkframe_time = I_GetPreciseTime() - ps_lua_thinkframe_time; ps_lua_thinkframe_time = I_GetPreciseTime() - ps_lua_thinkframe_time;
} }
@ -748,7 +748,7 @@ void P_Ticker(boolean run)
// Always move the camera. // Always move the camera.
P_RunChaseCameras(); P_RunChaseCameras();
LUAh_PostThinkFrame(); LUA_HOOK(PostThinkFrame);
if (run) if (run)
{ {
@ -802,7 +802,7 @@ void P_PreTicker(INT32 frames)
K_KartUpdatePosition(&players[i]); K_KartUpdatePosition(&players[i]);
// OK! Now that we got all of that sorted, players can think! // OK! Now that we got all of that sorted, players can think!
LUAh_PreThinkFrame(); LUA_HOOK(PreThinkFrame);
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
@ -825,7 +825,7 @@ void P_PreTicker(INT32 frames)
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
P_PlayerAfterThink(&players[i]); P_PlayerAfterThink(&players[i]);
LUAh_ThinkFrame(); LUA_HOOK(ThinkFrame);
// Run shield positioning // Run shield positioning
P_RunOverlays(); P_RunOverlays();
@ -833,7 +833,7 @@ void P_PreTicker(INT32 frames)
P_UpdateSpecials(); P_UpdateSpecials();
P_RespawnSpecials(); P_RespawnSpecials();
LUAh_PostThinkFrame(); LUA_HOOK(PostThinkFrame);
R_UpdateLevelInterpolators(); R_UpdateLevelInterpolators();
R_UpdateViewInterpolation(); R_UpdateViewInterpolation();

View file

@ -664,7 +664,7 @@ boolean P_EvaluateMusicStatus(UINT16 status, const char *musname)
break; break;
case JT_OTHER: // Other state case JT_OTHER: // Other state
result = LUAh_ShouldJingleContinue(&players[i], musname); result = LUA_HookShouldJingleContinue(&players[i], musname);
break; break;
case JT_NONE: // Null state case JT_NONE: // Null state
@ -3671,7 +3671,7 @@ boolean P_SpectatorJoinGame(player_t *player)
else else
changeto = (P_RandomFixed() & 1) + 1; changeto = (P_RandomFixed() & 1) + 1;
if (!LUAh_TeamSwitch(player, changeto, true, false, false)) if (!LUA_HookTeamSwitch(player, changeto, true, false, false))
return false; return false;
} }
@ -3697,7 +3697,7 @@ boolean P_SpectatorJoinGame(player_t *player)
{ {
if (localplayertable[i] == (player-players)) if (localplayertable[i] == (player-players))
{ {
LUAh_ViewpointSwitch(player, player, true); LUA_HookViewpointSwitch(player, player, true);
displayplayers[i] = (player-players); displayplayers[i] = (player-players);
break; break;
} }
@ -4207,7 +4207,7 @@ void P_PlayerThink(player_t *player)
if (player->playerstate == PST_DEAD) if (player->playerstate == PST_DEAD)
{ {
LUAh_PlayerThink(player); LUA_HookPlayer(player, HOOK(PlayerThink));
return; return;
} }
} }
@ -4256,7 +4256,7 @@ void P_PlayerThink(player_t *player)
else else
player->mo->renderflags &= ~RF_GHOSTLYMASK; player->mo->renderflags &= ~RF_GHOSTLYMASK;
P_DeathThink(player); P_DeathThink(player);
LUAh_PlayerThink(player); LUA_HookPlayer(player, HOOK(PlayerThink));
return; return;
} }
@ -4461,7 +4461,7 @@ void P_PlayerThink(player_t *player)
if (player->carry == CR_SLIDING) if (player->carry == CR_SLIDING)
player->carry = CR_NONE; player->carry = CR_NONE;
LUAh_PlayerThink(player); LUA_HookPlayer(player, HOOK(PlayerThink));
} }
// //
@ -4568,7 +4568,7 @@ void P_PlayerAfterThink(player_t *player)
if (player->followmobj) if (player->followmobj)
{ {
if (LUAh_FollowMobj(player, player->followmobj) || P_MobjWasRemoved(player->followmobj)) if (LUA_HookFollowMobj(player, player->followmobj) || P_MobjWasRemoved(player->followmobj))
{;} {;}
else else
{ {

View file

@ -2121,6 +2121,15 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32
{ {
char newmusic[7]; char newmusic[7];
struct MusicChange hook_param = {
newmusic,
&mflags,
&looping,
&position,
&prefadems,
&fadeinms
};
if (S_MusicDisabled() if (S_MusicDisabled()
|| demo.rewinding // Don't mess with music while rewinding! || demo.rewinding // Don't mess with music while rewinding!
|| demo.title) // SRB2Kart: Demos don't interrupt title screen music || demo.title) // SRB2Kart: Demos don't interrupt title screen music
@ -2128,7 +2137,7 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32
strncpy(newmusic, mmusic, 7); strncpy(newmusic, mmusic, 7);
if (LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms)) if (LUA_HookMusicChange(music_name, &hook_param))
return; return;
newmusic[6] = 0; newmusic[6] = 0;

View file

@ -1149,7 +1149,7 @@ void I_GetEvent(void)
M_SetupJoystickMenu(0); M_SetupJoystickMenu(0);
break; break;
case SDL_QUIT: case SDL_QUIT:
LUAh_GameQuit(true); LUA_HookBool(true, HOOK(GameQuit));
I_Quit(); I_Quit();
break; break;
} }

View file

@ -47,6 +47,7 @@
#include "lua_hudlib_drawlist.h" #include "lua_hudlib_drawlist.h"
#include "lua_hud.h" #include "lua_hud.h"
#include "lua_hook.h"
// SRB2Kart // SRB2Kart
#include "k_hud.h" // SRB2kart #include "k_hud.h" // SRB2kart
@ -962,7 +963,7 @@ luahook:
if (renderisnewtic) if (renderisnewtic)
{ {
LUA_HUD_ClearDrawList(luahuddrawlist_titlecard); LUA_HUD_ClearDrawList(luahuddrawlist_titlecard);
LUAh_TitleCardHUD(stplyr, luahuddrawlist_titlecard); LUA_HookHUD(luahuddrawlist_titlecard, HUD_HOOK(titlecard));
} }
LUA_HUD_DrawList(luahuddrawlist_titlecard); LUA_HUD_DrawList(luahuddrawlist_titlecard);
} }
@ -1009,7 +1010,7 @@ static void ST_overlayDrawer(void)
if (renderisnewtic) if (renderisnewtic)
{ {
LUA_HUD_ClearDrawList(luahuddrawlist_game); LUA_HUD_ClearDrawList(luahuddrawlist_game);
LUAh_GameHUD(stplyr, luahuddrawlist_game); LUA_HookHUD(luahuddrawlist_game, HUD_HOOK(game));
} }
LUA_HUD_DrawList(luahuddrawlist_game); LUA_HUD_DrawList(luahuddrawlist_game);
} }

View file

@ -478,7 +478,7 @@ void Y_IntermissionDrawer(void)
if (renderisnewtic) if (renderisnewtic)
{ {
LUA_HUD_ClearDrawList(luahuddrawlist_intermission); LUA_HUD_ClearDrawList(luahuddrawlist_intermission);
LUAh_IntermissionHUD(luahuddrawlist_intermission); LUA_HookHUD(luahuddrawlist_intermission, HUD_HOOK(intermission));
} }
LUA_HUD_DrawList(luahuddrawlist_intermission); LUA_HUD_DrawList(luahuddrawlist_intermission);
@ -777,7 +777,7 @@ void Y_Ticker(void)
if (paused || P_AutoPause()) if (paused || P_AutoPause())
return; return;
LUAh_IntermissionThinker(); LUA_HOOK(IntermissionThinker);
intertic++; intertic++;
@ -1371,7 +1371,7 @@ void Y_VoteTicker(void)
if (paused || P_AutoPause() || !voteclient.loaded) if (paused || P_AutoPause() || !voteclient.loaded)
return; return;
LUAh_VoteThinker(); LUA_HOOK(VoteThinker);
votetic++; votetic++;