port srb2 hooklib refactor (WIP)
lol lmao
This commit is contained in:
1 parent
799ed82532
commit
ca4bb191a4
24 files changed
+1086
-1698
No files matched your search
+2
-2
@@ -36,7 +36,7 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm
|
||||
return;
|
||||
|
||||
// Lua can handle it!
|
||||
if (LUAh_BotAI(sonic, tails, cmd))
|
||||
if (LUA_HookBotAI(sonic, tails, cmd))
|
||||
return;
|
||||
|
||||
if (tails->player->pflags & (PF_MACESPIN|PF_ITEMHANG))
|
||||
@@ -119,7 +119,7 @@ void B_BuildTiccmd(player_t *player, ticcmd_t *cmd)
|
||||
}
|
||||
|
||||
// Let Lua scripts build ticcmds
|
||||
if (LUAh_BotTiccmd(player, cmd))
|
||||
if (LUA_HookTiccmd(player, cmd, HOOK(BotTiccmd)))
|
||||
return;
|
||||
|
||||
// We don't have any main character AI, sorry. D:
|
||||
|
||||
@@ -160,6 +160,20 @@ LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);
|
||||
LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);
|
||||
LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
|
||||
|
||||
/* }====================================================== */
|
||||
|
||||
|
||||
/* compatibility with ref system */
|
||||
|
||||
/* pre-defined references */
|
||||
#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \
|
||||
(lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0))
|
||||
|
||||
#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref))
|
||||
|
||||
#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref))
|
||||
|
||||
#define luaL_reg luaL_Reg
|
||||
|
||||
/* }====================================================== */
|
||||
|
||||
|
||||
+4
-4
@@ -3125,7 +3125,7 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason)
|
||||
}
|
||||
}
|
||||
|
||||
LUAh_PlayerQuit(&players[playernum], reason); // Lua hook for player quitting
|
||||
LUA_HookPlayerQuit(&players[playernum], reason); // Lua hook for player quitting
|
||||
|
||||
if (playernum == displayplayers[0] && !demo.playback)
|
||||
displayplayers[0] = consoleplayer; // don't look through someone's view who isn't there
|
||||
@@ -4300,10 +4300,10 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
|
||||
|
||||
D_AddPostloadFiles();
|
||||
|
||||
LUAh_PlayerJoin(newplayernum);
|
||||
LUA_HookInt(newplayernum, HOOK(PlayerJoin));
|
||||
|
||||
if (newplayernum == consoleplayer)
|
||||
LUAh_ServerJoin();
|
||||
//if (newplayernum == consoleplayer)
|
||||
//LUA_ServerJoin();
|
||||
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
DRPC_UpdatePresence();
|
||||
|
||||
+1
-1
@@ -2961,7 +2961,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
|
||||
SetPlayerSkinByNum(0, cv_chooseskin.value-1);
|
||||
|
||||
//mapnumber = M_MapNumber(mapname[3], mapname[4]);
|
||||
//LUAh_MapChange(mapnumber);
|
||||
//LUA_HookInt(mapnumber, HOOK(MapChange));
|
||||
|
||||
demo.savemode = (cv_recordmultiplayerdemos.value == 2) ? DSM_WILLAUTOSAVE : DSM_NOTSAVING;
|
||||
demo.savebutton = 0;
|
||||
|
||||
@@ -365,6 +365,30 @@ typedef UINT32 tic_t;
|
||||
#define UINT2RGBA(a) (UINT32)((a&0xff)<<24)|((a&0xff00)<<8)|((a&0xff0000)>>8)|(((UINT32)a&0xff000000)>>24)
|
||||
#endif
|
||||
|
||||
#define TOSTR(x) #x
|
||||
|
||||
typedef UINT8 bitarray_t;
|
||||
|
||||
#define BIT_ARRAY_SIZE(n) (((n) + 7) >> 3)
|
||||
|
||||
static inline int
|
||||
in_bit_array (const bitarray_t * const array, const int value)
|
||||
{
|
||||
return (array[value >> 3] & (1<<(value & 7)));
|
||||
}
|
||||
|
||||
static inline void
|
||||
set_bit_array (bitarray_t * const array, const int value)
|
||||
{
|
||||
array[value >> 3] |= (1<<(value & 7));
|
||||
}
|
||||
|
||||
static inline void
|
||||
unset_bit_array (bitarray_t * const array, const int value)
|
||||
{
|
||||
array[value >> 3] &= ~(1<<(value & 7));
|
||||
}
|
||||
|
||||
typedef UINT64 precise_t;
|
||||
|
||||
#endif //__DOOMTYPE__
|
||||
+5
-5
@@ -1201,7 +1201,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
||||
-Making a Mario Kart 8 Deluxe tier baby mode that steers you away from walls and whatnot. You know what, do what you want!
|
||||
*/
|
||||
if (gamestate == GS_LEVEL)
|
||||
LUAh_PlayerCmd(player, cmd);
|
||||
LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd));
|
||||
|
||||
//Reset away view if a command is given.
|
||||
if ((cmd->forwardmove || cmd->sidemove || cmd->buttons)
|
||||
@@ -2395,7 +2395,7 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost)
|
||||
if (starpost) //Don't even bother with looking for a place to spawn.
|
||||
{
|
||||
P_MovePlayerToStarpost(playernum);
|
||||
LUAh_PlayerSpawn(&players[playernum]); // Lua hook for player spawning :)
|
||||
LUA_HookPlayer(&players[playernum], HOOK(PlayerSpawn)); // Lua hook for player spawning :)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2441,7 +2441,7 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost)
|
||||
}
|
||||
P_MovePlayerToSpawn(playernum, spawnpoint);
|
||||
|
||||
LUAh_PlayerSpawn(&players[playernum]); // Lua hook for player spawning :)
|
||||
LUA_HookPlayer(&players[playernum], HOOK(PlayerSpawn)); // Lua hook for player spawning :)
|
||||
}
|
||||
|
||||
mapthing_t *G_FindCTFStart(INT32 playernum)
|
||||
@@ -3955,7 +3955,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool
|
||||
F_StartCustomCutscene(mapheaderinfo[gamemap-1]->precutscenenum-1, true, resetplayer);
|
||||
else
|
||||
{
|
||||
LUAh_MapChange(gamemap);
|
||||
LUA_HookInt(gamemap, HOOK(MapChange));
|
||||
S_CheckMap();
|
||||
G_DoLoadLevel(resetplayer);
|
||||
}
|
||||
@@ -7076,7 +7076,7 @@ void G_DoPlayDemo(char *defdemoname)
|
||||
// didn't start recording right away.
|
||||
demo.deferstart = false;
|
||||
|
||||
//LUAh_MapChange(gamemap);
|
||||
//LUA_HookInt(gamemap, HOOK(MapChange));
|
||||
|
||||
displayplayers[0] = consoleplayer = 0;
|
||||
memset(playeringame,0,sizeof(playeringame));
|
||||
|
||||
+1
-1
@@ -1000,7 +1000,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.
|
||||
|
||||
if (LUAh_PlayerMsg(playernum, target, flags, msg, spam_eatmsg))
|
||||
if (LUA_HookPlayerMsg(playernum, target, flags, msg, spam_eatmsg))
|
||||
return;
|
||||
|
||||
if (spam_eatmsg)
|
||||
|
||||
+2
-2
@@ -535,10 +535,9 @@ UINT8 colortranslations[MAXTRANSLATIONS][16] = {
|
||||
*/
|
||||
void K_RainbowColormap(UINT8 *dest_colormap, UINT8 skincolor)
|
||||
{
|
||||
INT32 i;
|
||||
INT32 i, j;
|
||||
RGBA_t color;
|
||||
UINT8 brightness;
|
||||
INT32 j;
|
||||
UINT8 colorbrightnesses[16];
|
||||
UINT16 brightdif;
|
||||
INT32 temp;
|
||||
@@ -561,6 +560,7 @@ void K_RainbowColormap(UINT8 *dest_colormap, UINT8 skincolor)
|
||||
color = V_GetColor(i);
|
||||
SETBRIGHTNESS(brightness, color.s.red, color.s.green, color.s.blue);
|
||||
brightdif = 256;
|
||||
|
||||
for (j = 0; j < 16; j++)
|
||||
{
|
||||
temp = abs((INT16)brightness - (INT16)colorbrightnesses[j]);
|
||||
|
||||
+101
-88
@@ -13,91 +13,112 @@
|
||||
#include "r_defs.h"
|
||||
#include "d_player.h"
|
||||
|
||||
enum hook {
|
||||
hook_NetVars=0,
|
||||
hook_MapChange,
|
||||
hook_MapLoad,
|
||||
hook_PlayerJoin,
|
||||
hook_PreThinkFrame,
|
||||
hook_ThinkFrame,
|
||||
hook_PostThinkFrame,
|
||||
hook_MobjSpawn,
|
||||
hook_MobjCollide,
|
||||
hook_MobjMoveCollide,
|
||||
hook_TouchSpecial,
|
||||
hook_MobjFuse,
|
||||
hook_MobjThinker,
|
||||
hook_BossThinker,
|
||||
hook_ShouldDamage,
|
||||
hook_MobjDamage,
|
||||
hook_MobjDeath,
|
||||
hook_BossDeath,
|
||||
hook_MobjRemoved,
|
||||
hook_JumpSpecial,
|
||||
hook_AbilitySpecial,
|
||||
hook_SpinSpecial,
|
||||
hook_JumpSpinSpecial,
|
||||
hook_BotTiccmd,
|
||||
hook_BotAI,
|
||||
hook_LinedefExecute,
|
||||
hook_PlayerMsg,
|
||||
hook_HurtMsg,
|
||||
hook_PlayerSpawn,
|
||||
hook_PlayerQuit,
|
||||
hook_PlayerThink,
|
||||
hook_MusicChange,
|
||||
hook_ShouldSpin, //SRB2KART
|
||||
hook_ShouldExplode, //SRB2KART
|
||||
hook_ShouldSquish, //SRB2KART
|
||||
hook_PlayerSpin, //SRB2KART
|
||||
hook_PlayerExplode, //SRB2KART
|
||||
hook_PlayerSquish, //SRB2KART
|
||||
hook_PlayerCmd, //SRB2KART
|
||||
hook_IntermissionThinker, //SRB2KART
|
||||
hook_VoteThinker, //SRB2KART
|
||||
hook_ServerJoin, // SRB2KART - Saturn 32p
|
||||
/*
|
||||
* 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 (MobjMoveCollide),/* tritto */\
|
||||
X (TouchSpecial),/* P_TouchSpecialThing */\
|
||||
X (MobjFuse),/* when mobj->fuse runs out */\
|
||||
X (MobjThinker),/* P_MobjThinker, P_SceneryThinker */\
|
||||
X (BossThinker),/* P_GenericBossThinker */\
|
||||
X (ShouldDamage),/* P_DamageMobj (Should mobj take damage?) */\
|
||||
X (MobjDamage),/* P_DamageMobj (Mobj actually takes damage!) */\
|
||||
X (MobjDeath),/* P_KillMobj */\
|
||||
X (BossDeath),/* A_BossDeath */\
|
||||
X (MobjRemoved),/* P_RemoveMobj */\
|
||||
|
||||
#define HOOK_LIST(X) \
|
||||
X (NetVars),/* add to archive table (netsave) */\
|
||||
X (MapChange),/* (before map load) */\
|
||||
X (MapLoad),\
|
||||
X (PlayerJoin),/* Got_AddPlayer */\
|
||||
X (PreThinkFrame)/* frame (before mobj and player thinkers) */,\
|
||||
X (ThinkFrame),/* frame (after mobj and player thinkers) */\
|
||||
X (PostThinkFrame),/* frame (at end of tick, ie after overlays, precipitation, specials) */\
|
||||
X (JumpSpecial),/* P_DoJumpStuff (Any-jumping) */\
|
||||
X (AbilitySpecial),/* P_DoJumpStuff (Double-jumping) */\
|
||||
X (SpinSpecial),/* P_DoSpinAbility (Spin button effect) */\
|
||||
X (JumpSpinSpecial),/* P_DoJumpStuff (Spin button effect (mid-air)) */\
|
||||
X (BotTiccmd),/* B_BuildTiccmd */\
|
||||
X (PlayerMsg),/* chat messages */\
|
||||
X (HurtMsg),/* imhurttin */\
|
||||
X (PlayerSpawn),/* G_SpawnPlayer */\
|
||||
X (PlayerQuit),\
|
||||
X (IntermissionThinker),/* Y_Ticker */\
|
||||
X (PlayerThink),/* P_PlayerThink */\
|
||||
X (GameQuit),\
|
||||
X (PlayerCmd),/* building the player's ticcmd struct (Ported from SRB2Kart) */\
|
||||
X (MusicChange),\
|
||||
X (ShouldSpin),/*SRB2KART*/\
|
||||
X (ShouldExplode),/*SRB2KART*/\
|
||||
X (ShouldSquish),/*SRB2KART*/\
|
||||
X (PlayerSpin),/*SRB2KART*/\
|
||||
X (PlayerExplode),/*SRB2KART*/\
|
||||
X (PlayerSquish),/*SRB2KART*/\
|
||||
X (VoteThinker),/*SRB2KART*/\
|
||||
X (ServerJoin),/* SRB2KART - Saturn 32p*/\
|
||||
|
||||
#define STRING_HOOK_LIST(X) \
|
||||
X (BotAI),/* B_BuildTailsTiccmd by skin name */\
|
||||
X (LinedefExecute),\
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#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))
|
||||
|
||||
hook_MAX // last hook
|
||||
};
|
||||
extern const char *const hookNames[];
|
||||
|
||||
extern boolean hook_cmd_running; // This is used by PlayerCmd and lua_playerlib to prevent anything from being wirtten to player while we run PlayerCmd.
|
||||
extern int hook_defrosting;
|
||||
|
||||
void LUAh_MapChange(INT16 mapnumber); // Hook for map change (before load)
|
||||
void LUAh_MapLoad(void); // Hook for map load
|
||||
void LUAh_PlayerJoin(int playernum); // Hook for Got_AddPlayer
|
||||
void LUAh_PreThinkFrame(void); // Hook for frame (before mobj and player thinkers)
|
||||
void LUAh_ThinkFrame(void); // Hook for frame (after mobj and player thinkers)
|
||||
void LUAh_PostThinkFrame(void); // Hook for frame (at end of tick, ie after overlays, precipitation, specials)
|
||||
boolean LUAh_MobjHook(mobj_t *mo, enum hook which);
|
||||
boolean LUAh_PlayerHook(player_t *plr, enum hook which);
|
||||
#define LUAh_MobjSpawn(mo) LUAh_MobjHook(mo, hook_MobjSpawn) // Hook for P_SpawnMobj by mobj type
|
||||
UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which);
|
||||
#define LUAh_MobjCollide(thing1, thing2) LUAh_MobjCollideHook(thing1, thing2, hook_MobjCollide) // Hook for PIT_CheckThing by (thing) mobj type
|
||||
#define LUAh_MobjMoveCollide(thing1, thing2) LUAh_MobjCollideHook(thing1, thing2, hook_MobjMoveCollide) // Hook for PIT_CheckThing by (tmthing) mobj type
|
||||
boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher); // Hook for P_TouchSpecialThing by mobj type
|
||||
#define LUAh_MobjFuse(mo) LUAh_MobjHook(mo, hook_MobjFuse) // Hook for mobj->fuse == 0 by mobj type
|
||||
boolean LUAh_MobjThinker(mobj_t *mo); // Hook for P_MobjThinker or P_SceneryThinker by mobj type
|
||||
#define LUAh_BossThinker(mo) LUAh_MobjHook(mo, hook_BossThinker) // Hook for P_GenericBossThinker by mobj type
|
||||
UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage); // Hook for P_DamageMobj by mobj type (Should mobj take damage?)
|
||||
boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage); // Hook for P_DamageMobj by mobj type (Mobj actually takes damage!)
|
||||
boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source); // Hook for P_KillMobj by mobj type
|
||||
#define LUAh_BossDeath(mo) LUAh_MobjHook(mo, hook_BossDeath) // Hook for A_BossDeath by mobj type
|
||||
#define LUAh_MobjRemoved(mo) LUAh_MobjHook(mo, hook_MobjRemoved) // Hook for P_RemoveMobj by mobj type
|
||||
#define LUAh_JumpSpecial(player) LUAh_PlayerHook(player, hook_JumpSpecial) // Hook for P_DoJumpStuff (Any-jumping)
|
||||
#define LUAh_AbilitySpecial(player) LUAh_PlayerHook(player, hook_AbilitySpecial) // Hook for P_DoJumpStuff (Double-jumping)
|
||||
#define LUAh_SpinSpecial(player) LUAh_PlayerHook(player, hook_SpinSpecial) // Hook for P_DoSpinDash (Spin button effect)
|
||||
#define LUAh_JumpSpinSpecial(player) LUAh_PlayerHook(player, hook_JumpSpinSpecial) // Hook for P_DoJumpStuff (Spin button effect (mid-air))
|
||||
boolean LUAh_BotTiccmd(player_t *bot, ticcmd_t *cmd); // Hook for B_BuildTiccmd
|
||||
boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd); // Hook for B_BuildTailsTiccmd by skin name
|
||||
boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector); // Hook for linedef executors
|
||||
boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg, int mute); // Hook for chat 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
|
||||
void LUAh_PlayerQuit(player_t *plr, int reason); // Hook for player quitting
|
||||
boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping,
|
||||
UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms); // Hook for music changes
|
||||
void LUA_HookVoid(int hook);
|
||||
|
||||
int LUA_HookMobj(mobj_t *, int hook);
|
||||
int LUA_Hook2Mobj(mobj_t *, mobj_t *, int hook);
|
||||
void LUA_HookInt(INT32 integer, int hook);
|
||||
//void LUA_HookBool(boolean value, int hook);
|
||||
void LUA_HookBool(int hook);
|
||||
int LUA_HookPlayer(player_t *, int hook);
|
||||
int LUA_HookTiccmd(player_t *, ticcmd_t *, int hook);
|
||||
|
||||
void LUA_HookThinkFrame(void);
|
||||
int LUA_HookTouchSpecial(mobj_t *special, mobj_t *toucher);
|
||||
int LUA_HookShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage);
|
||||
int LUA_HookMobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage);
|
||||
int LUA_HookMobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source);
|
||||
int LUA_HookBotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd);
|
||||
void LUA_HookLinedefExecute(line_t *, mobj_t *, sector_t *);
|
||||
int LUA_HookPlayerMsg(int source, int target, int flags, char *msg, int mute);
|
||||
int LUA_HookHurtMsg(player_t *, mobj_t *inflictor, mobj_t *source);
|
||||
int LUA_HookPlayerCanDamage(player_t *, mobj_t *);
|
||||
void LUA_HookPlayerQuit(player_t *, int);
|
||||
int LUA_HookPlayerCmd(player_t *, ticcmd_t *);
|
||||
int LUA_HookMusicChange(const char *oldname, struct MusicChange *);
|
||||
int LUA_HookKey(INT32 keycode, int hooktype); // Hooks for key events
|
||||
|
||||
|
||||
// No clue what to do about these
|
||||
|
||||
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?
|
||||
@@ -106,11 +127,3 @@ UINT8 LUAh_ShouldSquish(player_t *player, mobj_t *inflictor, mobj_t *source); //
|
||||
boolean LUAh_PlayerSpin(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_SpinPlayer. Allows Lua to execute code and/or overwrite its behavior.
|
||||
boolean LUAh_PlayerExplode(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_ExplodePlayer. Allows Lua to execute code and/or overwrite its behavior.
|
||||
boolean LUAh_PlayerSquish(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_SquishPlayer. Allows Lua to execute code and/or overwrite its behavior.
|
||||
|
||||
void LUAh_ServerJoin(void); // SRB2KART - Saturn 32p: called by client when joining a server, allows lua to load any sort of config file
|
||||
|
||||
boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd); // Allows to write to player cmd before the game does anything with them.
|
||||
|
||||
void LUAh_IntermissionThinker(void); // Hook for Y_Ticker
|
||||
void LUAh_VoteThinker(void); // Hook for Y_VoteTicker
|
||||
#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink
|
||||
+868
-1555
File diff suppressed because it is too large.
Load diff
+4
-2
@@ -1397,7 +1397,8 @@ void LUA_Archive(savebuffer_t *save, boolean network)
|
||||
}
|
||||
WRITEUINT32(save->p, UINT32_MAX); // end of mobjs marker, replaces mobjnum.
|
||||
|
||||
LUAh_NetArchiveHook(NetArchive, save); // call the NetArchive hook in archive mode
|
||||
//LUA_HookNetArchive(NetArchive, save); // call the NetArchive hook in archive mode
|
||||
LUA_HookNetArchive(NetArchive); // call the NetArchive hook in archive mode
|
||||
}
|
||||
|
||||
ArchiveTables(&save->p);
|
||||
@@ -1437,7 +1438,8 @@ void LUA_UnArchive(savebuffer_t *save, boolean network)
|
||||
}
|
||||
} while(mobjnum != UINT32_MAX); // repeat until end of mobjs marker.
|
||||
|
||||
LUAh_NetArchiveHook(NetUnArchive, save); // call the NetArchive hook in unarchive mode
|
||||
//LUA_HookNetArchive(NetUnArchive, save); // call the NetArchive hook in unarchive mode
|
||||
LUA_HookNetArchive(NetUnArchive); // call the NetArchive hook in unarchive mode
|
||||
}
|
||||
|
||||
UnArchiveTables(&save->p, network);
|
||||
|
||||
+2
-1
@@ -74,7 +74,8 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum); // lua_consolelib.c
|
||||
void LUA_CVarChanged(const char *name); // lua_consolelib.c
|
||||
int Lua_optoption(lua_State *L, int narg, int def, int list_ref);
|
||||
int Lua_CreateFieldTable(lua_State *L, const char *const lst[]);
|
||||
void LUAh_NetArchiveHook(lua_CFunction archFunc, savebuffer_t *save);
|
||||
//void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save);
|
||||
void LUA_HookNetArchive(lua_CFunction archFunc);
|
||||
|
||||
// Console wrapper
|
||||
void COM_Lua_f(void);
|
||||
|
||||
+1
-1
@@ -2653,7 +2653,7 @@ void A_BossDeath(mobj_t *mo)
|
||||
}
|
||||
|
||||
bossjustdie:
|
||||
if (LUAh_BossDeath(mo))
|
||||
if (LUA_HookMobj(mo, MOBJ_HOOK(BossDeath)))
|
||||
return;
|
||||
else if (P_MobjWasRemoved(mo))
|
||||
return;
|
||||
|
||||
+8
-8
@@ -284,7 +284,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|
||||
if (special->flags & MF_BOSS && special->flags2 & MF2_FRET)
|
||||
return;
|
||||
|
||||
if (LUAh_TouchSpecial(special, toucher) || P_MobjWasRemoved(special))
|
||||
if (LUA_HookTouchSpecial(special, toucher) || P_MobjWasRemoved(special))
|
||||
return;
|
||||
|
||||
if (special->flags & MF_BOSS)
|
||||
@@ -1616,7 +1616,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source)
|
||||
target->flags2 &= ~(MF2_SKULLFLY|MF2_NIGHTSPULL);
|
||||
target->health = 0; // This makes it easy to check if something's dead elsewhere.
|
||||
|
||||
if (LUAh_MobjDeath(target, inflictor, source) || P_MobjWasRemoved(target))
|
||||
if (LUA_HookMobjDeath(target, inflictor, source) || P_MobjWasRemoved(target))
|
||||
return;
|
||||
|
||||
// SRB2kart
|
||||
@@ -2275,7 +2275,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
|
||||
// Everything above here can't be forced.
|
||||
if (!metalrecording)
|
||||
{
|
||||
UINT8 shouldForce = LUAh_ShouldDamage(target, inflictor, source, damage);
|
||||
UINT8 shouldForce = LUA_HookShouldDamage(target, inflictor, source, damage);
|
||||
if (P_MobjWasRemoved(target))
|
||||
return (shouldForce == 1); // mobj was removed
|
||||
if (shouldForce == 1)
|
||||
@@ -2316,7 +2316,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
|
||||
if (!force && target->fuse) // Invincible
|
||||
return false;
|
||||
|
||||
if (LUAh_MobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target))
|
||||
if (LUA_HookMobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target))
|
||||
return true;
|
||||
|
||||
if (target->health > 1)
|
||||
@@ -2342,7 +2342,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
|
||||
return false;
|
||||
|
||||
if (LUAh_MobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target))
|
||||
if (LUA_HookMobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target))
|
||||
return true;
|
||||
|
||||
if (target->health > 1)
|
||||
@@ -2350,7 +2350,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
|
||||
}
|
||||
else if (target->flags & MF_ENEMY)
|
||||
{
|
||||
if (LUAh_MobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target))
|
||||
if (LUA_HookMobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target))
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2372,14 +2372,14 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
|
||||
return false; // Don't hit yourself with your own paraloop, baka
|
||||
}
|
||||
|
||||
if (LUAh_MobjDamage(target, inflictor, source, damage))
|
||||
if (LUA_HookMobjDamage(target, inflictor, source, damage))
|
||||
return true;
|
||||
|
||||
P_NiGHTSDamage(target, source); // -5s :(
|
||||
return true;
|
||||
}
|
||||
|
||||
if (LUAh_MobjDamage(target, inflictor, source, damage))
|
||||
if (LUA_HookMobjDamage(target, inflictor, source, damage))
|
||||
return true;
|
||||
|
||||
if (!force && inflictor && (inflictor->flags & MF_FIRE))
|
||||
|
||||
+2
-2
@@ -444,7 +444,7 @@ static boolean 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))
|
||||
return true; // one of them was removed???
|
||||
if (shouldCollide == 1)
|
||||
@@ -453,7 +453,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
|
||||
return true; // force no collide
|
||||
}
|
||||
{
|
||||
UINT8 shouldCollide = LUAh_MobjMoveCollide(tmthing, thing); // checks hook for tmthing's type
|
||||
UINT8 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)
|
||||
|
||||
+8
-8
@@ -6226,7 +6226,7 @@ void P_MobjThinker(mobj_t *mobj)
|
||||
// Special thinker for scenery objects
|
||||
if (mobj->flags & MF_SCENERY)
|
||||
{
|
||||
if (LUAh_MobjThinker(mobj))
|
||||
if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjThinker)))
|
||||
return;
|
||||
|
||||
if (P_MobjWasRemoved(mobj))
|
||||
@@ -6924,7 +6924,7 @@ void P_MobjThinker(mobj_t *mobj)
|
||||
mobj->fuse--;
|
||||
if (!mobj->fuse)
|
||||
{
|
||||
if (!LUAh_MobjFuse(mobj))
|
||||
if (!LUA_HookMobj(mobj, MOBJ_HOOK(MobjFuse)))
|
||||
P_RemoveMobj(mobj);
|
||||
return;
|
||||
}
|
||||
@@ -6939,13 +6939,13 @@ void P_MobjThinker(mobj_t *mobj)
|
||||
// Check for a Lua thinker first
|
||||
if (!mobj->player)
|
||||
{
|
||||
if (LUAh_MobjThinker(mobj) || 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.
|
||||
LUAh_MobjThinker(mobj);
|
||||
LUA_HookMobj(mobj, MOBJ_HOOK(MobjThinker));
|
||||
if (P_MobjWasRemoved(mobj))
|
||||
return;
|
||||
}
|
||||
@@ -6970,7 +6970,7 @@ void P_MobjThinker(mobj_t *mobj)
|
||||
}
|
||||
else if (mobj->flags & MF_BOSS)
|
||||
{
|
||||
if (LUAh_BossThinker(mobj))
|
||||
if (LUA_HookMobj(mobj, MOBJ_HOOK(BossThinker)))
|
||||
{
|
||||
if (P_MobjWasRemoved(mobj))
|
||||
return;
|
||||
@@ -8942,7 +8942,7 @@ void P_MobjThinker(mobj_t *mobj)
|
||||
fixed_t x, y, z;
|
||||
mobj_t *flagmo, *newmobj;
|
||||
|
||||
if (!LUAh_MobjFuse(mobj) && !P_MobjWasRemoved(mobj))
|
||||
if (!LUA_HookMobj(mobj, MOBJ_HOOK(MobjFuse)) && !P_MobjWasRemoved(mobj))
|
||||
{
|
||||
switch (mobj->type)
|
||||
{
|
||||
@@ -9532,7 +9532,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 (LUAh_MobjSpawn(mobj))
|
||||
if (LUA_HookMobj(mobj, MOBJ_HOOK(MobjSpawn)))
|
||||
{
|
||||
if (P_MobjWasRemoved(mobj))
|
||||
return NULL;
|
||||
@@ -10067,7 +10067,7 @@ void P_RemoveMobj(mobj_t *mobj)
|
||||
return; // something already removing this mobj.
|
||||
|
||||
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.
|
||||
|
||||
// Rings only, please!
|
||||
|
||||
+2
-2
@@ -63,7 +63,7 @@
|
||||
|
||||
#include "md5.h" // map MD5
|
||||
|
||||
// for LUAh_MapLoad
|
||||
// for MapLoad hook
|
||||
#include "lua_script.h"
|
||||
#include "lua_hook.h"
|
||||
|
||||
@@ -2935,7 +2935,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate)
|
||||
}
|
||||
P_PreTicker(2);
|
||||
if (!reloadinggamestate)
|
||||
LUAh_MapLoad();
|
||||
LUA_HookInt(gamemap, HOOK(MapLoad));
|
||||
}
|
||||
|
||||
if (rendermode != render_none && !reloadinggamestate)
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@
|
||||
#include "hu_stuff.h"
|
||||
#include "m_misc.h"
|
||||
#include "m_cond.h" //unlock triggers
|
||||
#include "lua_hook.h" // LUAh_LinedefExecute
|
||||
#include "lua_hook.h" // LUA_HookLinedefExecute
|
||||
|
||||
#include "k_kart.h" // SRB2kart
|
||||
#include "console.h" // CON_LogMessage
|
||||
@@ -2850,7 +2850,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
|
||||
|
||||
case 443: // Calls a named Lua function
|
||||
if (line->text)
|
||||
LUAh_LinedefExecute(line, mo, callsec);
|
||||
LUA_HookLinedefExecute(line, mo, callsec);
|
||||
else
|
||||
CONS_Alert(CONS_WARNING, "Linedef %s is missing the hook name of the Lua function to call! (This should be given in the front texture fields)\n", sizeu1(line-lines));
|
||||
break;
|
||||
|
||||
+6
-6
@@ -529,7 +529,7 @@ void P_Ticker(boolean run)
|
||||
ps_checkposition_calls.value.i = 0;
|
||||
|
||||
PS_START_TIMING(ps_lua_prethinkframe_time);
|
||||
LUAh_PreThinkFrame();
|
||||
LUA_HOOK(PreThinkFrame);
|
||||
PS_STOP_TIMING(ps_lua_prethinkframe_time);
|
||||
|
||||
PS_START_TIMING(ps_playerthink_time);
|
||||
@@ -565,7 +565,7 @@ void P_Ticker(boolean run)
|
||||
}
|
||||
|
||||
PS_START_TIMING(ps_lua_thinkframe_time);
|
||||
LUAh_ThinkFrame();
|
||||
LUA_HookThinkFrame();
|
||||
PS_STOP_TIMING(ps_lua_thinkframe_time);
|
||||
}
|
||||
|
||||
@@ -669,7 +669,7 @@ void P_Ticker(boolean run)
|
||||
D_MapChange(gamemap, gametype, encoremode, true, 0, false, false);
|
||||
|
||||
PS_START_TIMING(ps_lua_postthinkframe_time);
|
||||
LUAh_PostThinkFrame();
|
||||
LUA_HOOK(PostThinkFrame);
|
||||
PS_STOP_TIMING(ps_lua_postthinkframe_time);
|
||||
}
|
||||
|
||||
@@ -726,7 +726,7 @@ void P_PreTicker(INT32 frames)
|
||||
|
||||
R_UpdateMobjInterpolators();
|
||||
|
||||
LUAh_PreThinkFrame();
|
||||
LUA_HOOK(PreThinkFrame);
|
||||
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
|
||||
@@ -755,7 +755,7 @@ void P_PreTicker(INT32 frames)
|
||||
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
|
||||
P_PlayerAfterThink(&players[i]);
|
||||
|
||||
LUAh_ThinkFrame();
|
||||
LUA_HookThinkFrame();
|
||||
|
||||
P_RunOverlays();
|
||||
P_RunShadows();
|
||||
@@ -763,7 +763,7 @@ void P_PreTicker(INT32 frames)
|
||||
P_UpdateSpecials();
|
||||
P_RespawnSpecials();
|
||||
|
||||
LUAh_PostThinkFrame();
|
||||
LUA_HOOK(PostThinkFrame);
|
||||
|
||||
R_UpdateLevelInterpolators();
|
||||
R_UpdateViewInterpolation();
|
||||
|
||||
+5
-5
@@ -4135,7 +4135,7 @@ void P_PlayerThink(player_t *player)
|
||||
}
|
||||
if (player->playerstate == PST_REBORN)
|
||||
{
|
||||
LUAh_PlayerThink(player);
|
||||
LUA_HookPlayer(player, HOOK(PlayerThink));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -4241,7 +4241,7 @@ void P_PlayerThink(player_t *player)
|
||||
|
||||
if (player->playerstate == PST_DEAD)
|
||||
{
|
||||
LUAh_PlayerThink(player);
|
||||
LUA_HookPlayer(player, HOOK(PlayerThink));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -4307,7 +4307,7 @@ void P_PlayerThink(player_t *player)
|
||||
else
|
||||
player->mo->flags2 &= ~MF2_SHADOW;
|
||||
P_DeathThink(player);
|
||||
LUAh_PlayerThink(player);
|
||||
LUA_HookPlayer(player, HOOK(PlayerThink));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4446,7 +4446,7 @@ void P_PlayerThink(player_t *player)
|
||||
|
||||
if (!player->mo)
|
||||
{
|
||||
LUAh_PlayerThink(player);
|
||||
LUA_HookPlayer(player, HOOK(PlayerThink));
|
||||
return; // P_MovePlayer removed player->mo.
|
||||
}
|
||||
|
||||
@@ -4623,7 +4623,7 @@ void P_PlayerThink(player_t *player)
|
||||
if (rendermode != render_none)
|
||||
DoABarrelRoll(player);
|
||||
|
||||
LUAh_PlayerThink(player);
|
||||
LUA_HookPlayer(player, HOOK(PlayerThink));
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "byteptr.h"
|
||||
#include "dehacked.h"
|
||||
#include "doomdef.h"
|
||||
#include "i_video.h"
|
||||
#include "r_data.h"
|
||||
#include "r_draw.h"
|
||||
|
||||
+10
-1
@@ -1763,6 +1763,15 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32
|
||||
{
|
||||
char newmusic[7] = {0};
|
||||
|
||||
struct MusicChange hook_param = {
|
||||
newmusic,
|
||||
&mflags,
|
||||
&looping,
|
||||
&position,
|
||||
&prefadems,
|
||||
&fadeinms
|
||||
};
|
||||
|
||||
if (S_MusicDisabled()
|
||||
|| demo.rewinding // Don't mess with music while rewinding!
|
||||
|| demo.title) // SRB2Kart: Demos don't interrupt title screen music
|
||||
@@ -1772,7 +1781,7 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32
|
||||
|
||||
S_CheckEventMus(newmusic);
|
||||
|
||||
if (LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms))
|
||||
if (LUA_HookMusicChange(music_name, &hook_param))
|
||||
return;
|
||||
|
||||
// No Music (empty string)
|
||||
|
||||
@@ -229,6 +229,16 @@ UINT32 S_GetMusicPosition(void);
|
||||
// Music Playback
|
||||
//
|
||||
|
||||
/* this is for the sake of the hook */
|
||||
struct MusicChange {
|
||||
char * newname;
|
||||
UINT16 * mflags;
|
||||
boolean * looping;
|
||||
UINT32 * position;
|
||||
UINT32 * prefadems;
|
||||
UINT32 * fadeinms;
|
||||
};
|
||||
|
||||
// Start music track, arbitrary, given its name, and set whether looping
|
||||
// note: music flags 12 bits for tracknum (gme, other formats with more than one track)
|
||||
// 13-15 aren't used yet
|
||||
|
||||
+3
-2
@@ -622,7 +622,8 @@ void Y_Ticker(void)
|
||||
if (paused || P_AutoPause())
|
||||
return;
|
||||
|
||||
LUAh_IntermissionThinker();
|
||||
LUA_HookBool(HOOK(IntermissionThinker));
|
||||
|
||||
|
||||
intertic++;
|
||||
|
||||
@@ -1258,7 +1259,7 @@ void Y_VoteTicker(void)
|
||||
if (paused || P_AutoPause() || !voteclient.loaded)
|
||||
return;
|
||||
|
||||
LUAh_VoteThinker();
|
||||
LUA_HOOK(VoteThinker);
|
||||
|
||||
votetic++;
|
||||
|
||||
|
||||
Reference in new issue
Block a user