Change MapChange so Lua returns the map number you change

This commit is contained in:
MPC 2018-11-30 14:01:40 -03:00
parent b1c41a193b
commit 54cae84849
4 changed files with 11 additions and 9 deletions

View file

@ -1749,6 +1749,9 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
UINT8 flags;
INT32 resetplayer = 1, lastgametype;
UINT8 skipprecutscene, FLS;
#ifdef HAVE_BLUA
INT16 mapnumber;
#endif
if (playernum != serverplayer && playernum != adminplayer)
{
@ -1810,7 +1813,8 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
}
#ifdef HAVE_BLUA
LUAh_MapChange();
mapnumber = M_MapNumber(mapname[3], mapname[4]);
LUAh_MapChange(mapnumber);
#endif
G_InitNew(ultimatemode, mapname, resetplayer, skipprecutscene);

View file

@ -2547,14 +2547,12 @@ void G_DoReborn(INT32 playernum)
}
}
else
#ifdef HAVE_BLUA
{
LUAh_MapChange();
#ifdef HAVE_BLUA
LUAh_MapChange(gamemap);
#endif
G_DoLoadLevel(true);
#ifdef HAVE_BLUA
}
#endif
}
else
{
@ -5091,7 +5089,7 @@ void G_DoPlayDemo(char *defdemoname)
demo_start = false;
#ifdef HAVE_BLUA
LUAh_MapChange();
LUAh_MapChange(gamemap);
#endif
displayplayer = consoleplayer = 0;
memset(playeringame,0,sizeof(playeringame));

View file

@ -48,7 +48,7 @@ enum hook {
};
extern const char *const hookNames[];
void LUAh_MapChange(void); // Hook for map change (before load)
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_ThinkFrame(void); // Hook for frame (after mobj and player thinkers)

View file

@ -314,14 +314,14 @@ boolean LUAh_PlayerHook(player_t *plr, enum hook which)
}
// Hook for map change (before load)
void LUAh_MapChange(void)
void LUAh_MapChange(INT16 mapnumber)
{
hook_p hookp;
if (!gL || !(hooksAvailable[hook_MapChange/8] & (1<<(hook_MapChange%8))))
return;
lua_settop(gL, 0);
lua_pushinteger(gL, gamemap);
lua_pushinteger(gL, mapnumber);
for (hookp = roothook; hookp; hookp = hookp->next)
if (hookp->type == hook_MapChange)