mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-12-18 17:01:20 +00:00
Add gametype parameter to G_SetCustomExitVars and G_ExitLevel
This commit is contained in:
parent
b9cab85df0
commit
fecf5616cc
4 changed files with 32 additions and 13 deletions
|
@ -2102,11 +2102,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);
|
||||
|
@ -4264,10 +4266,8 @@ 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);
|
||||
// Allow setting gametypes other than Co-Op in singleplayer
|
||||
// G_SetGametype(GT_COOP);
|
||||
}
|
||||
|
||||
// reset timelimit and pointlimit in race/coop, prevent stupid cheats
|
||||
|
|
|
@ -245,6 +245,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
|
||||
|
||||
|
|
30
src/g_game.c
30
src/g_game.c
|
@ -151,6 +151,7 @@ textprompt_t *textprompts[MAX_PROMPTS];
|
|||
|
||||
INT16 nextmapoverride;
|
||||
UINT8 skipstats;
|
||||
INT16 nextgametype = -1;
|
||||
|
||||
// Pointers to each CTF flag
|
||||
mobj_t *flagmobjs[MAXTEAMS];
|
||||
|
@ -3618,7 +3619,7 @@ void G_UpdateTeamSelection(void)
|
|||
}
|
||||
|
||||
//
|
||||
// Sets a new gametype, also setting gametype rules accordingly.
|
||||
// Sets a new gametype.
|
||||
//
|
||||
void G_SetGametype(INT16 gtype)
|
||||
{
|
||||
|
@ -4263,6 +4264,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,
|
||||
|
@ -4271,8 +4279,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));
|
||||
|
@ -4352,7 +4360,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.
|
||||
|
@ -4361,7 +4369,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))
|
||||
|
@ -4427,12 +4434,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;
|
||||
|
|
|
@ -3890,11 +3890,13 @@ static int lib_gSetCustomExitVars(lua_State *L)
|
|||
|
||||
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