mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Grand Prix Rank Points Hook
This commit is contained in:
parent
294e60bf8d
commit
49c8ebceed
3 changed files with 29 additions and 0 deletions
|
|
@ -21,6 +21,7 @@
|
|||
#include "m_random.h"
|
||||
#include "p_local.h"
|
||||
#include "r_things.h"
|
||||
#include "lua_hook.h" // LUA_HookGPRankPoints
|
||||
|
||||
struct grandprixinfo grandprixinfo;
|
||||
|
||||
|
|
@ -94,6 +95,8 @@ INT16 K_CalculateGPRankPoints(UINT8 position, UINT8 numplayers)
|
|||
points = 0;
|
||||
}
|
||||
|
||||
LUA_HookGPRankPoints(position, numplayers, &points);
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ automatically.
|
|||
X (GameQuit),\
|
||||
X (PlayerCmd),/* building the player's ticcmd struct */\
|
||||
X (VoteThinker),/* Y_VoteTicker */\
|
||||
X (GPRankPoints),/* K_CalculateGPRankPoints */\
|
||||
|
||||
#define STRING_HOOK_LIST(X) \
|
||||
X (SpecialExecute),\
|
||||
|
|
@ -146,6 +147,7 @@ void LUA_HookPlayerQuit(player_t *, kickreason_t);
|
|||
int LUA_HookTeamSwitch(player_t *, int newteam, boolean fromspectators, boolean tryingautobalance, boolean tryingscramble);
|
||||
int LUA_HookViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean forced);
|
||||
int LUA_HookSeenPlayer(player_t *player, player_t *seenfriend);
|
||||
int LUA_HookGPRankPoints(UINT8 position, UINT8 numplayers, INT16 *points);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
|
|
|||
|
|
@ -1007,4 +1007,28 @@ int LUA_HookSeenPlayer(player_t *player, player_t *seenfriend)
|
|||
return hook.status;
|
||||
}
|
||||
|
||||
static void res_gprankpoints(Hook_State *hook)
|
||||
{
|
||||
if (!lua_isnil(gL, -1))
|
||||
{
|
||||
INT16 *points = (INT16*)hook->userdata;
|
||||
*points = lua_tointeger(gL, -1);
|
||||
hook->status = true;
|
||||
}
|
||||
}
|
||||
|
||||
int LUA_HookGPRankPoints(UINT8 position, UINT8 numplayers, INT16 *points)
|
||||
{
|
||||
Hook_State hook;
|
||||
if (prepare_hook(&hook, 0, HOOK(GPRankPoints)))
|
||||
{
|
||||
hook.userdata = points;
|
||||
lua_pushinteger(gL, position);
|
||||
lua_pushinteger(gL, numplayers);
|
||||
lua_pushinteger(gL, *points);
|
||||
call_hooks(&hook, 1, res_gprankpoints);
|
||||
}
|
||||
return hook.status;
|
||||
}
|
||||
|
||||
boolean hook_cmd_running = false;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue