Hooklib macros names -> uppercase + documentation

This commit is contained in:
James R 2020-12-12 03:06:57 -08:00
parent 9ddeb5f589
commit 93e4f43e4b
16 changed files with 117 additions and 103 deletions

View file

@ -363,7 +363,7 @@ void B_BuildTiccmd(player_t *player, ticcmd_t *cmd)
CV_SetValue(&cv_analog[1], false);
// Let Lua scripts build ticcmds
if (LUA_HookTiccmd(player, cmd, Hook(BotTiccmd)))
if (LUA_HookTiccmd(player, cmd, HOOK(BotTiccmd)))
return;
// We don't have any main character AI, sorry. D:
@ -461,7 +461,7 @@ boolean B_CheckRespawn(player_t *player)
// B_RespawnBot doesn't do anything if the condition above this isn't met
{
UINT8 shouldForce = LUA_Hook2Mobj(sonic, tails, Mobj_Hook(BotRespawn));
UINT8 shouldForce = LUA_Hook2Mobj(sonic, tails, MOBJ_HOOK(BotRespawn));
if (P_MobjWasRemoved(sonic) || P_MobjWasRemoved(tails))
return (shouldForce == 1); // mobj was removed

View file

@ -3032,7 +3032,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
if (pnum == consoleplayer)
{
LUA_HookBool(false, Hook(GameQuit));
LUA_HookBool(false, HOOK(GameQuit));
#ifdef DUMPCONSISTENCY
if (msg == KICK_MSG_CON_FAIL) SV_SavedGame();
#endif
@ -3452,7 +3452,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
COM_BufAddText(va("sayto %d %s\n", newplayernum, motd));
if (!rejoined)
LUA_HookInt(newplayernum, Hook(PlayerJoin));
LUA_HookInt(newplayernum, HOOK(PlayerJoin));
}
static boolean SV_AddWaitingPlayers(const char *name, const char *name2)
@ -3732,7 +3732,7 @@ static void HandleConnect(SINT8 node)
static void HandleShutdown(SINT8 node)
{
(void)node;
LUA_HookBool(false, Hook(GameQuit));
LUA_HookBool(false, HOOK(GameQuit));
D_QuitNetGame();
CL_Reset();
D_StartTitle();
@ -3747,7 +3747,7 @@ static void HandleShutdown(SINT8 node)
static void HandleTimeout(SINT8 node)
{
(void)node;
LUA_HookBool(false, Hook(GameQuit));
LUA_HookBool(false, HOOK(GameQuit));
D_QuitNetGame();
CL_Reset();
D_StartTitle();

View file

@ -2103,7 +2103,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
}
mapnumber = M_MapNumber(mapname[3], mapname[4]);
LUA_HookInt(mapnumber, Hook(MapChange));
LUA_HookInt(mapnumber, HOOK(MapChange));
G_InitNew(ultimatemode, mapname, resetplayer, skipprecutscene, FLS);
if (demoplayback && !timingdemo)
@ -3612,7 +3612,7 @@ static void Command_Playintro_f(void)
*/
FUNCNORETURN static ATTRNORETURN void Command_Quit_f(void)
{
LUA_HookBool(true, Hook(GameQuit));
LUA_HookBool(true, HOOK(GameQuit));
I_Quit();
}
@ -4274,7 +4274,7 @@ void Command_ExitGame_f(void)
{
INT32 i;
LUA_HookBool(false, Hook(GameQuit));
LUA_HookBool(false, HOOK(GameQuit));
D_QuitNetGame();
CL_Reset();

View file

@ -1956,7 +1956,7 @@ void G_DoPlayDemo(char *defdemoname)
// Set skin
SetPlayerSkin(0, skin);
LUA_HookInt(gamemap, Hook(MapChange));
LUA_HookInt(gamemap, HOOK(MapChange));
displayplayer = consoleplayer = 0;
memset(playeringame,0,sizeof(playeringame));
playeringame[0] = true;

View file

@ -1689,7 +1689,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
cmd->angleturn = orighookangle;
LUA_HookTiccmd(player, cmd, Hook(PlayerCmd));
LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd));
extra = cmd->angleturn - orighookangle;
cmd->angleturn = origangle + extra;
@ -2740,7 +2740,7 @@ void G_SpawnPlayer(INT32 playernum)
P_SpawnPlayer(playernum);
G_MovePlayerToSpawnOrStarpost(playernum);
LUA_HookPlayer(&players[playernum], Hook(PlayerSpawn)); // Lua hook for player spawning :)
LUA_HookPlayer(&players[playernum], HOOK(PlayerSpawn)); // Lua hook for player spawning :)
}
void G_MovePlayerToSpawnOrStarpost(INT32 playernum)
@ -3119,7 +3119,7 @@ void G_DoReborn(INT32 playernum)
}
else
{
LUA_HookInt(gamemap, Hook(MapChange));
LUA_HookInt(gamemap, HOOK(MapChange));
titlecardforreload = true;
G_DoLoadLevel(true);
titlecardforreload = false;

View file

@ -14,7 +14,14 @@
#include "d_player.h"
#include "s_sound.h"
#define Mobj_Hook_List(X) \
/*
Do you know what an 'X Macro' is? Such a macro is called over each element of
a list and expands the input. I use it for the hook lists because both an enum
and array of hook names need to be kept in order. The X Macro handles this
automatically.
*/
#define MOBJ_HOOK_LIST(X) \
X (MobjSpawn),/* P_SpawnMobj */\
X (MobjCollide),/* PIT_CheckThing */\
X (MobjLineCollide),/* ditto */\
@ -33,7 +40,7 @@
X (MapThingSpawn),/* P_SpawnMapThing */\
X (FollowMobj),/* P_PlayerAfterThink Smiles mobj-following */\
#define Hook_List(X) \
#define HOOK_LIST(X) \
X (NetVars),/* add to archive table (netsave) */\
X (MapChange),/* (before map load) */\
X (MapLoad),\
@ -62,24 +69,33 @@
X (PlayerCmd),/* building the player's ticcmd struct (Ported from SRB2Kart) */\
X (MusicChange),\
#define String_Hook_List(X) \
#define STRING_HOOK_LIST(X) \
X (BotAI),/* B_BuildTailsTiccmd by skin name */\
X (LinedefExecute),\
X (ShouldJingleContinue),/* should jingle of the given music continue playing */\
#define Mobj_Hook(name) mobjhook_ ## name
#define Hook(name) hook_ ## name
#define String_Hook(name) stringhook_ ## name
/*
I chose to access the hook enums through a macro as well. This could provide
a hint to lookup the macro's definition instead of the enum's definition.
(Since each enumeration is not defined in the source code, but by the list
macros above, it is not greppable.) The name passed to the macro can also be
grepped and found in the lists above.
*/
enum { Mobj_Hook_List (Mobj_Hook) Mobj_Hook(MAX) };
enum { Hook_List (Hook) Hook(MAX) };
enum { String_Hook_List (String_Hook) String_Hook(MAX) };
#define MOBJ_HOOK(name) mobjhook_ ## name
#define HOOK(name) hook_ ## name
#define STRING_HOOK(name) stringhook_ ## name
enum { MOBJ_HOOK_LIST (MOBJ_HOOK) MOBJ_HOOK(MAX) };
enum { HOOK_LIST (HOOK) HOOK(MAX) };
enum { STRING_HOOK_LIST (STRING_HOOK) STRING_HOOK(MAX) };
/* dead simple, LUA_HOOK(GameQuit) */
#define LUA_HOOK(type) LUA_HookVoid(HOOK(type))
extern boolean hook_cmd_running;
/* dead simple, LUA_Hook(GameQuit) */
void LUA_Hook(int hook);
#define LUA_Hook(type) LUA_Hook(Hook(type))
void LUA_HookVoid(int hook);
int LUA_HookMobj(mobj_t *, int hook);
int LUA_Hook2Mobj(mobj_t *, mobj_t *, int hook);

View file

@ -27,17 +27,15 @@
#include "d_netcmd.h" // for cv_perfstats
#include "i_system.h" // I_GetPreciseTime
#undef LUA_Hook
/* =========================================================================
ABSTRACTION
========================================================================= */
static const char * const mobjHookNames[] = { Mobj_Hook_List (TOSTR) NULL };
static const char * const hookNames[] = { Hook_List (TOSTR) NULL };
static const char * const mobjHookNames[] = { MOBJ_HOOK_LIST (TOSTR) NULL };
static const char * const hookNames[] = { HOOK_LIST (TOSTR) NULL };
static const char * const stringHookNames[] = {
String_Hook_List (TOSTR) NULL
STRING_HOOK_LIST (TOSTR) NULL
};
/* TODO: remove when doomtype version is merged */
@ -62,11 +60,11 @@ typedef struct {
int ref;
} stringhook_t;
static hook_t hookIds[Hook(MAX)];
static hook_t mobjHookIds[NUMMOBJTYPES][Mobj_Hook(MAX)];
static hook_t hookIds[HOOK(MAX)];
static hook_t mobjHookIds[NUMMOBJTYPES][MOBJ_HOOK(MAX)];
// Lua tables are used to lookup string hook ids.
static stringhook_t stringHooks[String_Hook(MAX)];
static stringhook_t stringHooks[STRING_HOOK(MAX)];
// This will be indexed by hook id, the value of which fetches the registry.
static int * hookRefs;
@ -132,8 +130,8 @@ static void add_string_hook(lua_State *L, int type, int id)
switch (type)
{
case String_Hook(BotAI):
case String_Hook(ShouldJingleContinue):
case STRING_HOOK(BotAI):
case STRING_HOOK(ShouldJingleContinue):
if (lua_isstring(L, 3))
{ // lowercase copy
string = Z_StrDup(lua_tostring(L, 3));
@ -141,7 +139,7 @@ static void add_string_hook(lua_State *L, int type, int id)
}
break;
case String_Hook(LinedefExecute):
case STRING_HOOK(LinedefExecute):
string = Z_StrDup(luaL_checkstring(L, 3));
strupr(string);
break;
@ -197,15 +195,15 @@ static int lib_addHook(lua_State *L)
luaL_checktype(L, 2, LUA_TFUNCTION);
/* this is a very special case */
if (( type = hook_in_list(name, stringHookNames) ) < String_Hook(MAX))
if (( type = hook_in_list(name, stringHookNames) ) < STRING_HOOK(MAX))
{
add_string_hook(L, type, nextid);
}
else if (( type = hook_in_list(name, mobjHookNames) ) < Mobj_Hook(MAX))
else if (( type = hook_in_list(name, mobjHookNames) ) < MOBJ_HOOK(MAX))
{
add_mobj_hook(L, type, nextid);
}
else if (( type = hook_in_list(name, hookNames) ) < Hook(MAX))
else if (( type = hook_in_list(name, hookNames) ) < HOOK(MAX))
{
add_hook(&hookIds[type], nextid);
}
@ -544,7 +542,7 @@ int LUA_Hook2Mobj(mobj_t *t1, mobj_t *t2, int hook_type)
return hook.status;
}
void LUA_Hook(int type)
void LUA_HookVoid(int type)
{
Hook_State hook;
if (prepare_hook(&hook, 0, type))
@ -590,12 +588,12 @@ int LUA_HookTiccmd(player_t *player, ticcmd_t *cmd, int hook_type)
LUA_PushUserdata(gL, player, META_PLAYER);
LUA_PushUserdata(gL, cmd, META_TICCMD);
if (hook_type == Hook(PlayerCmd))
if (hook_type == HOOK(PlayerCmd))
hook_cmd_running = true;
call_hooks(&hook, 2, 1, res_true);
if (hook_type == Hook(PlayerCmd))
if (hook_type == HOOK(PlayerCmd))
hook_cmd_running = false;
}
return hook.status;
@ -607,7 +605,7 @@ int LUA_HookTiccmd(player_t *player, ticcmd_t *cmd, int hook_type)
void LUA_HookThinkFrame(void)
{
const int type = Hook(ThinkFrame);
const int type = HOOK(ThinkFrame);
// variables used by perf stats
int hook_index = 0;
@ -651,7 +649,7 @@ void LUA_HookThinkFrame(void)
int LUA_HookMobjLineCollide(mobj_t *mobj, line_t *line)
{
Hook_State hook;
if (prepare_mobj_hook(&hook, 0, Mobj_Hook(MobjLineCollide), mobj->type))
if (prepare_mobj_hook(&hook, 0, MOBJ_HOOK(MobjLineCollide), mobj->type))
{
LUA_PushUserdata(gL, mobj, META_MOBJ);
LUA_PushUserdata(gL, line, META_LINE);
@ -663,7 +661,7 @@ int LUA_HookMobjLineCollide(mobj_t *mobj, line_t *line)
int LUA_HookTouchSpecial(mobj_t *special, mobj_t *toucher)
{
Hook_State hook;
if (prepare_mobj_hook(&hook, false, Mobj_Hook(TouchSpecial), special->type))
if (prepare_mobj_hook(&hook, false, MOBJ_HOOK(TouchSpecial), special->type))
{
LUA_PushUserdata(gL, special, META_MOBJ);
LUA_PushUserdata(gL, toucher, META_MOBJ);
@ -700,19 +698,19 @@ static int damage_hook
int LUA_HookShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype)
{
return damage_hook(target, inflictor, source, damage, damagetype,
Mobj_Hook(ShouldDamage), 5, res_force);
MOBJ_HOOK(ShouldDamage), 5, res_force);
}
int LUA_HookMobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype)
{
return damage_hook(target, inflictor, source, damage, damagetype,
Mobj_Hook(MobjDamage), 5, res_true);
MOBJ_HOOK(MobjDamage), 5, res_true);
}
int LUA_HookMobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damagetype)
{
return damage_hook(target, inflictor, source, 0, damagetype,
Mobj_Hook(MobjDeath), 4, res_true);
MOBJ_HOOK(MobjDeath), 4, res_true);
}
typedef struct {
@ -737,12 +735,12 @@ static void res_botai(Hook_State *hook)
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)
#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")
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)
{
@ -752,7 +750,7 @@ static void res_botai(Hook_State *hook)
}
lua_pop(gL, 1); // pop value
#undef check
#undef CHECK
}
} else {
while (fields < 8)
@ -775,7 +773,7 @@ int LUA_HookBotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
Hook_State hook;
BotAI_State botai;
if (prepare_string_hook(&hook, false, String_Hook(BotAI), skin))
if (prepare_string_hook(&hook, false, STRING_HOOK(BotAI), skin))
{
LUA_PushUserdata(gL, sonic, META_MOBJ);
LUA_PushUserdata(gL, tails, META_MOBJ);
@ -795,7 +793,7 @@ void LUA_HookLinedefExecute(line_t *line, mobj_t *mo, sector_t *sector)
{
Hook_State hook;
if (prepare_string_hook
(&hook, 0, String_Hook(LinedefExecute), line->stringargs[0]))
(&hook, 0, STRING_HOOK(LinedefExecute), line->stringargs[0]))
{
LUA_PushUserdata(gL, line, META_LINE);
LUA_PushUserdata(gL, mo, META_MOBJ);
@ -807,7 +805,7 @@ void LUA_HookLinedefExecute(line_t *line, mobj_t *mo, sector_t *sector)
int LUA_HookPlayerMsg(int source, int target, int flags, char *msg)
{
Hook_State hook;
if (prepare_hook(&hook, false, Hook(PlayerMsg)))
if (prepare_hook(&hook, false, HOOK(PlayerMsg)))
{
LUA_PushUserdata(gL, &players[source], META_PLAYER); // Source player
if (flags & 2 /*HU_CSAY*/) { // csay TODO: make HU_CSAY accessible outside hu_stuff.c
@ -832,7 +830,7 @@ int LUA_HookPlayerMsg(int source, int target, int flags, char *msg)
int LUA_HookHurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8 damagetype)
{
Hook_State hook;
if (prepare_hook(&hook, false, Hook(HurtMsg)))
if (prepare_hook(&hook, false, HOOK(HurtMsg)))
{
LUA_PushUserdata(gL, player, META_PLAYER);
LUA_PushUserdata(gL, inflictor, META_MOBJ);
@ -845,7 +843,7 @@ int LUA_HookHurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8 d
void LUA_HookNetArchive(lua_CFunction archFunc)
{
const hook_t * map = &hookIds[Hook(NetVars)];
const hook_t * map = &hookIds[HOOK(NetVars)];
Hook_State hook;
/* this is a remarkable case where the stack isn't reset */
if (map->numHooks > 0)
@ -874,7 +872,7 @@ void LUA_HookNetArchive(lua_CFunction archFunc)
int LUA_HookMapThingSpawn(mobj_t *mobj, mapthing_t *mthing)
{
Hook_State hook;
if (prepare_mobj_hook(&hook, false, Mobj_Hook(MapThingSpawn), mobj->type))
if (prepare_mobj_hook(&hook, false, MOBJ_HOOK(MapThingSpawn), mobj->type))
{
LUA_PushUserdata(gL, mobj, META_MOBJ);
LUA_PushUserdata(gL, mthing, META_MAPTHING);
@ -886,7 +884,7 @@ int LUA_HookMapThingSpawn(mobj_t *mobj, mapthing_t *mthing)
int LUA_HookFollowMobj(player_t *player, mobj_t *mobj)
{
Hook_State hook;
if (prepare_mobj_hook(&hook, false, Mobj_Hook(FollowMobj), mobj->type))
if (prepare_mobj_hook(&hook, false, MOBJ_HOOK(FollowMobj), mobj->type))
{
LUA_PushUserdata(gL, player, META_PLAYER);
LUA_PushUserdata(gL, mobj, META_MOBJ);
@ -898,7 +896,7 @@ int LUA_HookFollowMobj(player_t *player, mobj_t *mobj)
int LUA_HookPlayerCanDamage(player_t *player, mobj_t *mobj)
{
Hook_State hook;
if (prepare_hook(&hook, 0, Hook(PlayerCanDamage)))
if (prepare_hook(&hook, 0, HOOK(PlayerCanDamage)))
{
LUA_PushUserdata(gL, player, META_PLAYER);
LUA_PushUserdata(gL, mobj, META_MOBJ);
@ -910,7 +908,7 @@ int LUA_HookPlayerCanDamage(player_t *player, mobj_t *mobj)
void LUA_HookPlayerQuit(player_t *plr, kickreason_t reason)
{
Hook_State hook;
if (prepare_hook(&hook, 0, Hook(PlayerQuit)))
if (prepare_hook(&hook, 0, HOOK(PlayerQuit)))
{
LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit
lua_pushinteger(gL, reason); // Reason for quitting
@ -921,7 +919,7 @@ void LUA_HookPlayerQuit(player_t *plr, kickreason_t reason)
int LUA_HookTeamSwitch(player_t *player, int newteam, boolean fromspectators, boolean tryingautobalance, boolean tryingscramble)
{
Hook_State hook;
if (prepare_hook(&hook, true, Hook(TeamSwitch)))
if (prepare_hook(&hook, true, HOOK(TeamSwitch)))
{
LUA_PushUserdata(gL, player, META_PLAYER);
lua_pushinteger(gL, newteam);
@ -936,7 +934,7 @@ int LUA_HookTeamSwitch(player_t *player, int newteam, boolean fromspectators, bo
int LUA_HookViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean forced)
{
Hook_State hook;
if (prepare_hook(&hook, 0, Hook(ViewpointSwitch)))
if (prepare_hook(&hook, 0, HOOK(ViewpointSwitch)))
{
LUA_PushUserdata(gL, player, META_PLAYER);
LUA_PushUserdata(gL, newdisplayplayer, META_PLAYER);
@ -953,7 +951,7 @@ int LUA_HookViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolea
int LUA_HookSeenPlayer(player_t *player, player_t *seenfriend)
{
Hook_State hook;
if (prepare_hook(&hook, true, Hook(SeenPlayer)))
if (prepare_hook(&hook, true, HOOK(SeenPlayer)))
{
LUA_PushUserdata(gL, player, META_PLAYER);
LUA_PushUserdata(gL, seenfriend, META_PLAYER);
@ -970,7 +968,7 @@ int LUA_HookShouldJingleContinue(player_t *player, const char *musname)
{
Hook_State hook;
if (prepare_string_hook
(&hook, false, String_Hook(ShouldJingleContinue), musname))
(&hook, false, STRING_HOOK(ShouldJingleContinue), musname))
{
LUA_PushUserdata(gL, player, META_PLAYER);
push_string();
@ -1033,7 +1031,7 @@ static void res_musicchange(Hook_State *hook)
int LUA_HookMusicChange(const char *oldname, struct MusicChange *param)
{
const int type = Hook(MusicChange);
const int type = HOOK(MusicChange);
const hook_t * map = &hookIds[type];
Hook_State hook;

View file

@ -6937,7 +6937,7 @@ static void M_SelectableClearMenus(INT32 choice)
static void M_UltimateCheat(INT32 choice)
{
(void)choice;
LUA_HookBool(true, Hook(GameQuit));
LUA_HookBool(true, HOOK(GameQuit));
I_Quit();
}
@ -13371,7 +13371,7 @@ void M_QuitResponse(INT32 ch)
if (ch != 'y' && ch != KEY_ENTER)
return;
LUA_HookBool(true, Hook(GameQuit));
LUA_HookBool(true, HOOK(GameQuit));
if (!(netgame || cv_debug))
{
S_ResetCaptions();

View file

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

View file

@ -937,7 +937,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
}
{
UINT8 shouldCollide = LUA_Hook2Mobj(thing, tmthing, Mobj_Hook(MobjCollide)); // 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))
return true; // one of them was removed???
if (shouldCollide == 1)
@ -945,7 +945,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
else if (shouldCollide == 2)
return true; // force no collide
shouldCollide = LUA_Hook2Mobj(tmthing, thing, Mobj_Hook(MobjMoveCollide)); // 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))
return true; // one of them was removed???
if (shouldCollide == 1)

View file

@ -1844,7 +1844,7 @@ void P_XYMovement(mobj_t *mo)
B_MoveBlocked(player);
}
if (LUA_HookMobj(mo, Mobj_Hook(MobjMoveBlocked)))
if (LUA_HookMobj(mo, MOBJ_HOOK(MobjMoveBlocked)))
{
if (P_MobjWasRemoved(mo))
return;
@ -7509,7 +7509,7 @@ static void P_RosySceneryThink(mobj_t *mobj)
static void P_MobjSceneryThink(mobj_t *mobj)
{
if (LUA_HookMobj(mobj, Mobj_Hook(MobjThinker)))
if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjThinker)))
return;
if (P_MobjWasRemoved(mobj))
return;
@ -7857,7 +7857,7 @@ static void P_MobjSceneryThink(mobj_t *mobj)
if (!mobj->fuse)
{
if (!LUA_HookMobj(mobj, Mobj_Hook(MobjFuse)))
if (!LUA_HookMobj(mobj, MOBJ_HOOK(MobjFuse)))
P_RemoveMobj(mobj);
return;
}
@ -7916,7 +7916,7 @@ static void P_MobjSceneryThink(mobj_t *mobj)
mobj->fuse--;
if (!mobj->fuse)
{
if (!LUA_HookMobj(mobj, Mobj_Hook(MobjFuse)))
if (!LUA_HookMobj(mobj, MOBJ_HOOK(MobjFuse)))
P_RemoveMobj(mobj);
return;
}
@ -7945,7 +7945,7 @@ static boolean P_MobjPushableThink(mobj_t *mobj)
static boolean P_MobjBossThink(mobj_t *mobj)
{
if (LUA_HookMobj(mobj, Mobj_Hook(BossThinker)))
if (LUA_HookMobj(mobj, MOBJ_HOOK(BossThinker)))
{
if (P_MobjWasRemoved(mobj))
return false;
@ -9872,7 +9872,7 @@ static boolean P_FuseThink(mobj_t *mobj)
if (mobj->fuse)
return true;
if (LUA_HookMobj(mobj, Mobj_Hook(MobjFuse)) || P_MobjWasRemoved(mobj))
if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjFuse)) || P_MobjWasRemoved(mobj))
;
else if (mobj->info->flags & MF_MONITOR)
{
@ -10048,13 +10048,13 @@ void P_MobjThinker(mobj_t *mobj)
// Check for a Lua thinker first
if (!mobj->player)
{
if (LUA_HookMobj(mobj, Mobj_Hook(MobjThinker)) || P_MobjWasRemoved(mobj))
if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjThinker)) || P_MobjWasRemoved(mobj))
return;
}
else if (!mobj->player->spectator)
{
// You cannot short-circuit the player thinker like you can other thinkers.
LUA_HookMobj(mobj, Mobj_Hook(MobjThinker));
LUA_HookMobj(mobj, MOBJ_HOOK(MobjThinker));
if (P_MobjWasRemoved(mobj))
return;
}
@ -10525,7 +10525,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!
// Avoid using P_RemoveMobj on the newly created mobj in "MobjSpawn" Lua hooks!
if (LUA_HookMobj(mobj, Mobj_Hook(MobjSpawn)))
if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjSpawn)))
{
if (P_MobjWasRemoved(mobj))
return NULL;
@ -10912,7 +10912,7 @@ void P_RemoveMobj(mobj_t *mobj)
return; // something already removing this mobj.
mobj->thinker.function.acp1 = (actionf_p1)P_RemoveThinkerDelayed; // shh. no recursing.
LUA_HookMobj(mobj, Mobj_Hook(MobjRemoved));
LUA_HookMobj(mobj, MOBJ_HOOK(MobjRemoved));
mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; // needed for P_UnsetThingPosition, etc. to work.
// Rings only, please!

View file

@ -4271,7 +4271,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1);
}
P_PreTicker(2);
LUA_HookInt(gamemap, Hook(MapLoad));
LUA_HookInt(gamemap, HOOK(MapLoad));
}
// No render mode or reloading gamestate, stop here.

View file

@ -656,7 +656,7 @@ void P_Ticker(boolean run)
ps_lua_mobjhooks = 0;
ps_checkposition_calls = 0;
LUA_Hook(PreThinkFrame);
LUA_HOOK(PreThinkFrame);
ps_playerthink_time = I_GetPreciseTime();
for (i = 0; i < MAXPLAYERS; i++)
@ -760,7 +760,7 @@ void P_Ticker(boolean run)
if (modeattacking)
G_GhostTicker();
LUA_Hook(PostThinkFrame);
LUA_HOOK(PostThinkFrame);
}
P_MapEnd();
@ -783,7 +783,7 @@ void P_PreTicker(INT32 frames)
{
P_MapStart();
LUA_Hook(PreThinkFrame);
LUA_HOOK(PreThinkFrame);
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
@ -819,7 +819,7 @@ void P_PreTicker(INT32 frames)
P_UpdateSpecials();
P_RespawnSpecials();
LUA_Hook(PostThinkFrame);
LUA_HOOK(PostThinkFrame);
P_MapEnd();
}

View file

@ -1860,7 +1860,7 @@ void P_SpawnShieldOrb(player_t *player)
I_Error("P_SpawnShieldOrb: player->mo is NULL!\n");
#endif
if (LUA_HookPlayer(player, Hook(ShieldSpawn)))
if (LUA_HookPlayer(player, HOOK(ShieldSpawn)))
return;
if (player->powers[pw_shield] & SH_FORCE)
@ -4581,7 +4581,7 @@ static void P_DoSpinAbility(player_t *player, ticcmd_t *cmd)
if (cmd->buttons & BT_SPIN)
{
if (LUA_HookPlayer(player, Hook(SpinSpecial)))
if (LUA_HookPlayer(player, HOOK(SpinSpecial)))
return;
}
@ -5047,7 +5047,7 @@ static boolean P_PlayerShieldThink(player_t *player, ticcmd_t *cmd, mobj_t *lock
}
}
}
if (cmd->buttons & BT_SPIN && !LUA_HookPlayer(player, Hook(ShieldSpecial))) // Spin button effects
if (cmd->buttons & BT_SPIN && !LUA_HookPlayer(player, HOOK(ShieldSpecial))) // Spin button effects
{
// Force stop
if ((player->powers[pw_shield] & ~(SH_FORCEHP|SH_STACK)) == SH_FORCE)
@ -5171,7 +5171,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd)
// and you don't have a shield, do it!
P_DoSuperTransformation(player, false);
}
else if (!LUA_HookPlayer(player, Hook(JumpSpinSpecial)))
else if (!LUA_HookPlayer(player, HOOK(JumpSpinSpecial)))
switch (player->charability)
{
case CA_THOK:
@ -5244,7 +5244,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd)
if (cmd->buttons & BT_JUMP && !player->exiting && !P_PlayerInPain(player))
{
if (LUA_HookPlayer(player, Hook(JumpSpecial)))
if (LUA_HookPlayer(player, HOOK(JumpSpecial)))
;
// all situations below this require jump button not to be pressed already
else if (player->pflags & PF_JUMPDOWN)
@ -5279,7 +5279,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd)
}*/
else if (player->pflags & PF_JUMPED)
{
if (!LUA_HookPlayer(player, Hook(AbilitySpecial)))
if (!LUA_HookPlayer(player, HOOK(AbilitySpecial)))
switch (player->charability)
{
case CA_THOK:
@ -5472,7 +5472,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd)
}
else if (player->pflags & PF_THOKKED)
{
if (!LUA_HookPlayer(player, Hook(AbilitySpecial)))
if (!LUA_HookPlayer(player, HOOK(AbilitySpecial)))
switch (player->charability)
{
case CA_FLY:
@ -11479,7 +11479,7 @@ void P_PlayerThink(player_t *player)
}
if (player->playerstate == PST_REBORN)
{
LUA_HookPlayer(player, Hook(PlayerThink));
LUA_HookPlayer(player, HOOK(PlayerThink));
return;
}
}
@ -11583,7 +11583,7 @@ void P_PlayerThink(player_t *player)
if (player->playerstate == PST_DEAD)
{
LUA_HookPlayer(player, Hook(PlayerThink));
LUA_HookPlayer(player, HOOK(PlayerThink));
return;
}
}
@ -11704,7 +11704,7 @@ void P_PlayerThink(player_t *player)
{
player->mo->flags2 &= ~MF2_SHADOW;
P_DeathThink(player);
LUA_HookPlayer(player, Hook(PlayerThink));
LUA_HookPlayer(player, HOOK(PlayerThink));
return;
}
@ -11746,7 +11746,7 @@ void P_PlayerThink(player_t *player)
{
if (P_SpectatorJoinGame(player))
{
LUA_HookPlayer(player, Hook(PlayerThink));
LUA_HookPlayer(player, HOOK(PlayerThink));
return; // player->mo was removed.
}
}
@ -11851,7 +11851,7 @@ void P_PlayerThink(player_t *player)
if (!player->mo)
{
LUA_HookPlayer(player, Hook(PlayerThink));
LUA_HookPlayer(player, HOOK(PlayerThink));
return; // P_MovePlayer removed player->mo.
}
@ -12305,7 +12305,7 @@ void P_PlayerThink(player_t *player)
}
#undef dashmode
LUA_HookPlayer(player, Hook(PlayerThink));
LUA_HookPlayer(player, HOOK(PlayerThink));
/*
// Colormap verification

View file

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

View file

@ -927,7 +927,7 @@ void Y_Ticker(void)
if (paused || P_AutoPause())
return;
LUA_Hook(IntermissionThinker);
LUA_HOOK(IntermissionThinker);
intertic++;