* 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); lua_pushinteger(L, titlemap);
return 1; return 1;
} else if (fastcmp(word,"titlemapinaction")) { } else if (fastcmp(word,"titlemapinaction")) {
lua_pushboolean(L, titlemapinaction); lua_pushboolean(L, (titlemapinaction != TITLEMAP_OFF));
return 1; return 1;
} else if (fastcmp(word,"gametype")) { } else if (fastcmp(word,"gametype")) {
lua_pushinteger(L, gametype); lua_pushinteger(L, gametype);

View File

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

View File

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

View File

@ -1636,10 +1636,19 @@ void G_DoLoadLevel(boolean resetplayer)
Y_EndIntermission(); Y_EndIntermission();
// cleanup // cleanup
if (titlemaptransition) if (titlemapinaction == TITLEMAP_LOADING)
titlemaptransition = false; {
if (W_CheckNumForName(G_BuildMapName(gamemap)) == LUMPERROR)
{
titlemap = 0; // let's not infinite recursion ok
Command_ExitGame_f();
return;
}
titlemapinaction = TITLEMAP_RUNNING;
}
else else
titlemapinaction = false; titlemapinaction = TITLEMAP_OFF;
G_SetGamestate(GS_LEVEL); G_SetGamestate(GS_LEVEL);
@ -1650,7 +1659,7 @@ void G_DoLoadLevel(boolean resetplayer)
} }
// Setup the level. // Setup the level.
if (!P_SetupLevel(false)) if (!P_SetupLevel(false)) // this never returns false?
{ {
// fail so reset game stuff // fail so reset game stuff
Command_ExitGame_f(); 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 /// ... as long as this isn't a titlemap transition, that is
if (!titlemapinaction) if (!titlemapinaction)
S_Start(); S_Start();
else
S_ChangeMusicInternal("_title", looptitle);
// Let's fade to black here // Let's fade to black here
// But only if we didn't do the special stage wipe // But only if we didn't do the special stage wipe