* Prevent crash if you go to a map and it doesn't exist.

* Handle music fix in smarter way.
* Enums!
This commit is contained in:
toasterbabe 2017-05-09 11:09:58 +01:00
parent 3a4e091ba6
commit 7f83e0d134
5 changed files with 33 additions and 20 deletions

View File

@ -8646,7 +8646,7 @@ static inline int lib_getenum(lua_State *L)
lua_pushinteger(L, titlemap);
return 1;
} else if (fastcmp(word,"titlemapinaction")) {
lua_pushboolean(L, titlemapinaction);
lua_pushboolean(L, (titlemapinaction != TITLEMAP_OFF));
return 1;
} else if (fastcmp(word,"gametype")) {
lua_pushinteger(L, gametype);

View File

@ -38,8 +38,7 @@
// 0 = text, 1 = art screen
static INT32 finalecount;
INT32 titlescrollspeed = 80;
boolean titlemapinaction = false;
boolean titlemaptransition = false;
UINT8 titlemapinaction = TITLEMAP_OFF;
static INT32 timetonext; // Delay between screen changes
static INT32 continuetime; // Short delay when continuing
@ -1421,6 +1420,8 @@ void F_GameEndTicker(void)
// ==============
void F_StartTitleScreen(void)
{
S_ChangeMusicInternal("_title", looptitle);
if (gamestate != GS_TITLESCREEN && gamestate != GS_WAITINGPLAYERS)
finalecount = 0;
else
@ -1431,7 +1432,7 @@ void F_StartTitleScreen(void)
mapthing_t *startpos;
gamestate_t prevwipegamestate = wipegamestate;
titlemapinaction = titlemaptransition = true;
titlemapinaction = TITLEMAP_LOADING;
gamemap = titlemap;
if (!mapheaderinfo[gamemap-1])
@ -1440,7 +1441,10 @@ void F_StartTitleScreen(void)
maptol = mapheaderinfo[gamemap-1]->typeoflevel;
globalweather = mapheaderinfo[gamemap-1]->weather;
G_DoLoadLevel(true); // handles music change
G_DoLoadLevel(true);
if (!titlemap)
return;
players[displayplayer].playerstate = PST_DEAD; // Don't spawn the player in dummy (I'm still a filthy cheater)
// Set Default Position
@ -1465,21 +1469,16 @@ void F_StartTitleScreen(void)
camera.x = camera.y = camera.z = camera.angle = camera.aiming = 0;
camera.subsector = NULL; // toast is filthy too
}
camera.chase = true;
camera.height = 0;
//camera.x = camera.y = camera.height = camera.aiming = 0;
//camera.z = 128*FRACUNIT;
//CON_ClearHUD();
wipegamestate = prevwipegamestate;
}
else
{
titlemapinaction = false;
titlemapinaction = TITLEMAP_OFF;
gamemap = 1; // g_game.c
S_ChangeMusicInternal("_title", looptitle);
CON_ClearHUD();
}

View File

@ -61,8 +61,15 @@ void F_ContinueTicker(void);
void F_ContinueDrawer(void);
extern INT32 titlescrollspeed;
extern boolean titlemapinaction;
extern boolean titlemaptransition;
typedef enum
{
TITLEMAP_OFF = 0,
TITLEMAP_LOADING,
TITLEMAP_RUNNING
} titlemap_enum;
extern UINT8 titlemapinaction;
//
// WIPE

View File

@ -1636,10 +1636,19 @@ void G_DoLoadLevel(boolean resetplayer)
Y_EndIntermission();
// cleanup
if (titlemaptransition)
titlemaptransition = false;
if (titlemapinaction == TITLEMAP_LOADING)
{
if (W_CheckNumForName(G_BuildMapName(gamemap)) == LUMPERROR)
{
titlemap = 0; // let's not infinite recursion ok
Command_ExitGame_f();
return;
}
titlemapinaction = TITLEMAP_RUNNING;
}
else
titlemapinaction = false;
titlemapinaction = TITLEMAP_OFF;
G_SetGamestate(GS_LEVEL);
@ -1650,7 +1659,7 @@ void G_DoLoadLevel(boolean resetplayer)
}
// Setup the level.
if (!P_SetupLevel(false))
if (!P_SetupLevel(false)) // this never returns false?
{
// fail so reset game stuff
Command_ExitGame_f();

View File

@ -2646,8 +2646,6 @@ boolean P_SetupLevel(boolean skipprecip)
/// ... as long as this isn't a titlemap transition, that is
if (!titlemapinaction)
S_Start();
else
S_ChangeMusicInternal("_title", looptitle);
// Let's fade to black here
// But only if we didn't do the special stage wipe