mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-21 12:01:05 +00:00
Add gametype parameter to G_SetCustomExitVars and G_ExitLevel
This commit is contained in:
parent
57592a566a
commit
86367e4ec1
4 changed files with 36 additions and 19 deletions
|
@ -2120,11 +2120,13 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
|
|||
|
||||
lastgametype = gametype;
|
||||
gametype = READUINT8(*cp);
|
||||
G_SetGametype(gametype); // I fear putting that macro as an argument
|
||||
|
||||
if (gametype < 0 || gametype >= gametypecount)
|
||||
gametype = lastgametype;
|
||||
else if (gametype != lastgametype)
|
||||
else
|
||||
G_SetGametype(gametype);
|
||||
|
||||
if (gametype != lastgametype)
|
||||
D_GameTypeChanged(lastgametype); // emulate consvar_t behavior for gametype
|
||||
|
||||
skipprecutscene = ((flags & (1<<2)) != 0);
|
||||
|
@ -4252,9 +4254,6 @@ void D_GameTypeChanged(INT32 lastgametype)
|
|||
else if (!multiplayer && !netgame)
|
||||
{
|
||||
G_SetGametype(GT_COOP);
|
||||
// These shouldn't matter anymore
|
||||
//CV_Set(&cv_itemrespawntime, cv_itemrespawntime.defaultvalue);
|
||||
//CV_SetValue(&cv_itemrespawn, 0);
|
||||
}
|
||||
|
||||
// reset timelimit and pointlimit in race/coop, prevent stupid cheats
|
||||
|
|
|
@ -249,6 +249,7 @@ extern textprompt_t *textprompts[MAX_PROMPTS];
|
|||
// For the Custom Exit linedef.
|
||||
extern INT16 nextmapoverride;
|
||||
extern UINT8 skipstats;
|
||||
extern INT16 nextgametype;
|
||||
|
||||
extern UINT32 ssspheres; // Total # of spheres in a level
|
||||
|
||||
|
|
32
src/g_game.c
32
src/g_game.c
|
@ -156,6 +156,7 @@ textprompt_t *textprompts[MAX_PROMPTS];
|
|||
|
||||
INT16 nextmapoverride;
|
||||
UINT8 skipstats;
|
||||
INT16 nextgametype = -1;
|
||||
|
||||
// Pointers to each CTF flag
|
||||
mobj_t *redflag;
|
||||
|
@ -3461,9 +3462,7 @@ UINT32 gametypedefaultrules[NUMGAMETYPES] =
|
|||
};
|
||||
|
||||
//
|
||||
// G_SetGametype
|
||||
//
|
||||
// Set a new gametype, also setting gametype rules accordingly. Yay!
|
||||
// Sets a new gametype.
|
||||
//
|
||||
void G_SetGametype(INT16 gtype)
|
||||
{
|
||||
|
@ -4053,6 +4052,13 @@ static void G_DoCompleted(void)
|
|||
nextmap = 1100-1; // No infinite loop for you
|
||||
}
|
||||
|
||||
INT16 gametype_to_use;
|
||||
|
||||
if (nextgametype >= 0 && nextgametype < gametypecount)
|
||||
gametype_to_use = nextgametype;
|
||||
else
|
||||
gametype_to_use = gametype;
|
||||
|
||||
// If nextmap is actually going to get used, make sure it points to
|
||||
// a map of the proper gametype -- skip levels that don't support
|
||||
// the current gametype. (Helps avoid playing boss levels in Race,
|
||||
|
@ -4061,8 +4067,8 @@ static void G_DoCompleted(void)
|
|||
{
|
||||
if (nextmap >= 0 && nextmap < NUMMAPS)
|
||||
{
|
||||
register INT16 cm = nextmap;
|
||||
UINT32 tolflag = G_TOLFlag(gametype);
|
||||
INT16 cm = nextmap;
|
||||
UINT32 tolflag = G_TOLFlag(gametype_to_use);
|
||||
UINT8 visitedmap[(NUMMAPS+7)/8];
|
||||
|
||||
memset(visitedmap, 0, sizeof (visitedmap));
|
||||
|
@ -4142,7 +4148,7 @@ static void G_DoCompleted(void)
|
|||
if (cv_advancemap.value == 0) // Stay on same map.
|
||||
nextmap = prevmap;
|
||||
else if (cv_advancemap.value == 2) // Go to random map.
|
||||
nextmap = RandMap(G_TOLFlag(gametype), prevmap);
|
||||
nextmap = RandMap(G_TOLFlag(gametype_to_use), prevmap);
|
||||
}
|
||||
|
||||
// We are committed to this map now.
|
||||
|
@ -4151,7 +4157,6 @@ static void G_DoCompleted(void)
|
|||
if (nextmap < NUMMAPS && !mapheaderinfo[nextmap])
|
||||
P_AllocMapHeader(nextmap);
|
||||
|
||||
// If the current gametype has no intermission screen set, then don't start it.
|
||||
Y_DetermineIntermissionType();
|
||||
|
||||
if ((skipstats && !modeattacking) || (modeattacking && stagefailed) || (intertype == int_none))
|
||||
|
@ -4217,12 +4222,21 @@ static void G_DoWorldDone(void)
|
|||
{
|
||||
if (server)
|
||||
{
|
||||
INT16 gametype_to_use;
|
||||
|
||||
if (nextgametype >= 0 && nextgametype < gametypecount)
|
||||
gametype_to_use = nextgametype;
|
||||
else
|
||||
gametype_to_use = gametype;
|
||||
|
||||
if (gametyperules & GTR_CAMPAIGN)
|
||||
// don't reset player between maps
|
||||
D_MapChange(nextmap+1, gametype, ultimatemode, false, 0, false, false);
|
||||
D_MapChange(nextmap+1, gametype_to_use, ultimatemode, false, 0, false, false);
|
||||
else
|
||||
// resetplayer in match/chaos/tag/CTF/race for more equality
|
||||
D_MapChange(nextmap+1, gametype, ultimatemode, true, 0, false, false);
|
||||
D_MapChange(nextmap+1, gametype_to_use, ultimatemode, true, 0, false, false);
|
||||
|
||||
nextgametype = -1;
|
||||
}
|
||||
|
||||
gameaction = ga_nothing;
|
||||
|
|
|
@ -3826,7 +3826,7 @@ static int lib_gDoReborn(lua_State *L)
|
|||
}
|
||||
|
||||
// Another Lua function that doesn't actually exist!
|
||||
// Sets nextmapoverride & skipstats without instantly ending the level, for instances where other sources should be exiting the level, like normal signposts.
|
||||
// Sets nextmapoverride, skipstats and nextgametype without instantly ending the level, for instances where other sources should be exiting the level, like normal signposts.
|
||||
static int lib_gSetCustomExitVars(lua_State *L)
|
||||
{
|
||||
int n = lua_gettop(L); // Num arguments
|
||||
|
@ -3835,18 +3835,21 @@ static int lib_gSetCustomExitVars(lua_State *L)
|
|||
|
||||
// LUA EXTENSION: Custom exit like support
|
||||
// Supported:
|
||||
// G_SetCustomExitVars(); [reset to defaults]
|
||||
// G_SetCustomExitVars(int) [nextmap override only]
|
||||
// G_SetCustomExitVars(nil, int) [skipstats only]
|
||||
// G_SetCustomExitVars(int, int) [both of the above]
|
||||
// G_SetCustomExitVars(); [reset to defaults]
|
||||
// G_SetCustomExitVars(int) [nextmap override only]
|
||||
// G_SetCustomExitVars(nil, int) [skipstats only]
|
||||
// G_SetCustomExitVars(int, int) [both of the above]
|
||||
// G_SetCustomExitVars(int, int, int) [nextmapoverride, skipstats and nextgametype]
|
||||
|
||||
nextmapoverride = 0;
|
||||
skipstats = 0;
|
||||
nextgametype = -1;
|
||||
|
||||
if (n >= 1)
|
||||
{
|
||||
nextmapoverride = (INT16)luaL_optinteger(L, 1, 0);
|
||||
skipstats = (INT16)luaL_optinteger(L, 2, 0);
|
||||
nextgametype = (INT16)luaL_optinteger(L, 3, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue