Keeping the lua_gettop(gL) thing, otherwise the player/reason values will be pushed once to the stack each for every hook. Thanks MonsterIestyn!

This commit is contained in:
Prisima the Fox 2016-11-25 15:20:41 -05:00
parent b1ce5896aa
commit d788cb7676
1 changed files with 5 additions and 1 deletions

View File

@ -810,7 +810,11 @@ void LUAh_PlayerQuit(player_t *plr, int reason)
for (hookp = roothook; hookp; hookp = hookp->next)
if (hookp->type == hook_PlayerQuit)
{
LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit
if (lua_gettop(gL) == 0)
{
LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit
lua_pushinteger(gL, reason); // Reason for quitting
}
lua_pushinteger(gL, reason); // Reason for quitting
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);