Merge branch 'playerthink-hook' into 'next'

PlayerThink Hook

See merge request STJr/SRB2!557
This commit is contained in:
James R 2020-01-10 15:58:30 -05:00
commit a16c444166
3 changed files with 32 additions and 1 deletions

View file

@ -57,6 +57,7 @@ enum hook {
hook_TeamSwitch, hook_TeamSwitch,
hook_ViewpointSwitch, hook_ViewpointSwitch,
hook_SeenPlayer, hook_SeenPlayer,
hook_PlayerThink,
hook_MAX // last hook hook_MAX // last hook
}; };
@ -108,5 +109,6 @@ UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean
#ifdef SEENAMES #ifdef SEENAMES
boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend); // Hook for MT_NAMECHECK boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend); // Hook for MT_NAMECHECK
#endif #endif
#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink
#endif #endif

View file

@ -68,6 +68,7 @@ const char *const hookNames[hook_MAX+1] = {
"TeamSwitch", "TeamSwitch",
"ViewpointSwitch", "ViewpointSwitch",
"SeenPlayer", "SeenPlayer",
"PlayerThink",
NULL NULL
}; };
@ -216,6 +217,7 @@ static int lib_addHook(lua_State *L)
case hook_SeenPlayer: case hook_SeenPlayer:
case hook_ShieldSpawn: case hook_ShieldSpawn:
case hook_ShieldSpecial: case hook_ShieldSpecial:
case hook_PlayerThink:
lastp = &playerhooks; lastp = &playerhooks;
break; break;
case hook_LinedefExecute: case hook_LinedefExecute:

View file

@ -11572,7 +11572,12 @@ void P_PlayerThink(player_t *player)
player->playerstate = PST_REBORN; player->playerstate = PST_REBORN;
} }
if (player->playerstate == PST_REBORN) if (player->playerstate == PST_REBORN)
{
#ifdef HAVE_BLUA
LUAh_PlayerThink(player);
#endif
return; return;
}
} }
#ifdef SEENAMES #ifdef SEENAMES
@ -11673,7 +11678,12 @@ void P_PlayerThink(player_t *player)
player->lives = 0; player->lives = 0;
if (player->playerstate == PST_DEAD) if (player->playerstate == PST_DEAD)
{
#ifdef HAVE_BLUA
LUAh_PlayerThink(player);
#endif
return; return;
}
} }
} }
@ -11792,7 +11802,9 @@ void P_PlayerThink(player_t *player)
{ {
player->mo->flags2 &= ~MF2_SHADOW; player->mo->flags2 &= ~MF2_SHADOW;
P_DeathThink(player); P_DeathThink(player);
#ifdef HAVE_BLUA
LUAh_PlayerThink(player);
#endif
return; return;
} }
@ -11833,7 +11845,12 @@ void P_PlayerThink(player_t *player)
if (player->spectator && cmd->buttons & BT_ATTACK && !player->powers[pw_flashing] && G_GametypeHasSpectators()) if (player->spectator && cmd->buttons & BT_ATTACK && !player->powers[pw_flashing] && G_GametypeHasSpectators())
{ {
if (P_SpectatorJoinGame(player)) if (P_SpectatorJoinGame(player))
{
#ifdef HAVE_BLUA
LUAh_PlayerThink(player);
#endif
return; // player->mo was removed. return; // player->mo was removed.
}
} }
// Even if not NiGHTS, pull in nearby objects when walking around as John Q. Elliot. // Even if not NiGHTS, pull in nearby objects when walking around as John Q. Elliot.
@ -11935,7 +11952,12 @@ void P_PlayerThink(player_t *player)
} }
if (!player->mo) if (!player->mo)
{
#ifdef HAVE_BLUA
LUAh_PlayerThink(player);
#endif
return; // P_MovePlayer removed player->mo. return; // P_MovePlayer removed player->mo.
}
// deez New User eXperiences. // deez New User eXperiences.
{ {
@ -12367,6 +12389,11 @@ void P_PlayerThink(player_t *player)
dashmode = 0; dashmode = 0;
} }
#undef dashmode #undef dashmode
#ifdef HAVE_BLUA
LUAh_PlayerThink(player);
#endif
/* /*
// Colormap verification // Colormap verification
{ {