mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-28 04:00:41 +00:00
Merge pull request #353 from monster-psychic-cat/lua_mapchange
Change MapChange so Lua returns the map number you change
This commit is contained in:
commit
6c0e0b9d08
4 changed files with 11 additions and 9 deletions
|
@ -1756,6 +1756,9 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
|
||||||
UINT8 flags;
|
UINT8 flags;
|
||||||
INT32 resetplayer = 1, lastgametype;
|
INT32 resetplayer = 1, lastgametype;
|
||||||
UINT8 skipprecutscene, FLS;
|
UINT8 skipprecutscene, FLS;
|
||||||
|
#ifdef HAVE_BLUA
|
||||||
|
INT16 mapnumber;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (playernum != serverplayer && playernum != adminplayer)
|
if (playernum != serverplayer && playernum != adminplayer)
|
||||||
{
|
{
|
||||||
|
@ -1817,7 +1820,8 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_BLUA
|
#ifdef HAVE_BLUA
|
||||||
LUAh_MapChange();
|
mapnumber = M_MapNumber(mapname[3], mapname[4]);
|
||||||
|
LUAh_MapChange(mapnumber);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
G_InitNew(ultimatemode, mapname, resetplayer, skipprecutscene);
|
G_InitNew(ultimatemode, mapname, resetplayer, skipprecutscene);
|
||||||
|
|
|
@ -2552,14 +2552,12 @@ void G_DoReborn(INT32 playernum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#ifdef HAVE_BLUA
|
|
||||||
{
|
{
|
||||||
LUAh_MapChange();
|
#ifdef HAVE_BLUA
|
||||||
|
LUAh_MapChange(gamemap);
|
||||||
#endif
|
#endif
|
||||||
G_DoLoadLevel(true);
|
G_DoLoadLevel(true);
|
||||||
#ifdef HAVE_BLUA
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -5128,7 +5126,7 @@ void G_DoPlayDemo(char *defdemoname)
|
||||||
demo_start = false;
|
demo_start = false;
|
||||||
|
|
||||||
#ifdef HAVE_BLUA
|
#ifdef HAVE_BLUA
|
||||||
LUAh_MapChange();
|
LUAh_MapChange(gamemap);
|
||||||
#endif
|
#endif
|
||||||
displayplayer = consoleplayer = 0;
|
displayplayer = consoleplayer = 0;
|
||||||
memset(playeringame,0,sizeof(playeringame));
|
memset(playeringame,0,sizeof(playeringame));
|
||||||
|
|
|
@ -49,7 +49,7 @@ enum hook {
|
||||||
};
|
};
|
||||||
extern const char *const hookNames[];
|
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_MapLoad(void); // Hook for map load
|
||||||
void LUAh_PlayerJoin(int playernum); // Hook for Got_AddPlayer
|
void LUAh_PlayerJoin(int playernum); // Hook for Got_AddPlayer
|
||||||
void LUAh_ThinkFrame(void); // Hook for frame (after mobj and player thinkers)
|
void LUAh_ThinkFrame(void); // Hook for frame (after mobj and player thinkers)
|
||||||
|
|
|
@ -315,14 +315,14 @@ boolean LUAh_PlayerHook(player_t *plr, enum hook which)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hook for map change (before load)
|
// Hook for map change (before load)
|
||||||
void LUAh_MapChange(void)
|
void LUAh_MapChange(INT16 mapnumber)
|
||||||
{
|
{
|
||||||
hook_p hookp;
|
hook_p hookp;
|
||||||
if (!gL || !(hooksAvailable[hook_MapChange/8] & (1<<(hook_MapChange%8))))
|
if (!gL || !(hooksAvailable[hook_MapChange/8] & (1<<(hook_MapChange%8))))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lua_settop(gL, 0);
|
lua_settop(gL, 0);
|
||||||
lua_pushinteger(gL, gamemap);
|
lua_pushinteger(gL, mapnumber);
|
||||||
|
|
||||||
for (hookp = roothook; hookp; hookp = hookp->next)
|
for (hookp = roothook; hookp; hookp = hookp->next)
|
||||||
if (hookp->type == hook_MapChange)
|
if (hookp->type == hook_MapChange)
|
||||||
|
|
Loading…
Reference in a new issue