- fixing some issues. Level transitions in Duke are working now.

This commit is contained in:
Christoph Oelckers 2020-09-04 00:20:32 +02:00
parent e5e8c02f1d
commit 77f96a1c75
5 changed files with 17 additions and 9 deletions

View file

@ -236,7 +236,7 @@ void ChangeLevel(MapRecord* map, int skill)
{ {
Net_WriteByte(DEM_CHANGEMAP); Net_WriteByte(DEM_CHANGEMAP);
Net_WriteByte(skill); Net_WriteByte(skill);
Net_WriteString(map->labelName); Net_WriteString(map? map->labelName : nullptr);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View file

@ -139,7 +139,9 @@ static void GameTicker()
g_nextskill = -1; g_nextskill = -1;
FX_StopAllSounds(); FX_StopAllSounds();
FX_SetReverb(0); FX_SetReverb(0);
gi->NextLevel(currentLevel, -1); gi->FreeLevelData();
gamestate = GS_LEVEL;
gi->NextLevel(g_nextmap, -1);
break; break;
case ga_completed: case ga_completed:
@ -149,7 +151,8 @@ static void GameTicker()
{ {
// if the same level is restarted, skip any progression stuff like summary screens or cutscenes. // if the same level is restarted, skip any progression stuff like summary screens or cutscenes.
gi->FreeLevelData(); gi->FreeLevelData();
gi->NextLevel(currentLevel, g_nextskill); gamestate = GS_LEVEL;
gi->NextLevel(g_nextmap, g_nextskill);
} }
else else
gi->LevelCompleted(g_nextmap, g_nextskill); gi->LevelCompleted(g_nextmap, g_nextskill);
@ -157,13 +160,15 @@ static void GameTicker()
case ga_nextlevel: case ga_nextlevel:
gi->FreeLevelData(); gi->FreeLevelData();
gi->NextLevel(currentLevel, g_nextskill); gamestate = GS_LEVEL;
gi->NextLevel(g_nextmap, g_nextskill);
break; break;
case ga_newgame: case ga_newgame:
FX_StopAllSounds(); FX_StopAllSounds();
FX_SetReverb(0); FX_SetReverb(0);
gi->FreeLevelData(); gi->FreeLevelData();
gamestate = GS_LEVEL;
gi->NewGame(g_nextmap, g_nextskill); gi->NewGame(g_nextmap, g_nextskill);
break; break;
@ -289,6 +294,7 @@ void Display()
switch (gamestate) switch (gamestate)
{ {
case GS_MENUSCREEN: case GS_MENUSCREEN:
case GS_FULLCONSOLE:
gi->DrawBackground(); gi->DrawBackground();
break; break;
@ -314,6 +320,7 @@ void Display()
break; break;
default: default:
twod->ClearScreen();
break; break;
} }
@ -392,7 +399,7 @@ void TryRunTics (void)
bool doWait = cl_capfps || pauseext || (r_NoInterpolate && !M_IsAnimated()); bool doWait = cl_capfps || pauseext || (r_NoInterpolate && !M_IsAnimated());
// get real tics // get real tics
if (doWait && gamestate != GS_INTERMISSION) // GS_INTERMISSION needs uncapped frame rate. if (doWait && gamestate != GS_INTERMISSION && gamestate != GS_INTRO) // GS_INTERMISSION needs uncapped frame rate.
{ {
entertic = I_WaitForTic (oldentertics); entertic = I_WaitForTic (oldentertics);
} }

View file

@ -415,8 +415,8 @@ class ScreenJobRunner
int index = -1; int index = -1;
float screenfade; float screenfade;
bool clearbefore; bool clearbefore;
uint64_t startTime = -1; int64_t startTime = -1;
uint64_t lastTime = -1; int64_t lastTime = -1;
int actionState; int actionState;
int terminateState; int terminateState;
@ -474,7 +474,7 @@ public:
auto now = I_nsTime(); auto now = I_nsTime();
bool processed = job.job->ProcessInput(); bool processed = job.job->ProcessInput();
bool skiprequest = inputState.CheckAllInput() && !processed; bool skiprequest = inputState.CheckAllInput() && !processed;
if (startTime == -1) startTime = now; if (startTime == -1) lastTime = startTime = now;
if (M_Active()) if (M_Active())
{ {

View file

@ -879,6 +879,7 @@ public:
int Frame(uint64_t clock, bool skiprequest) int Frame(uint64_t clock, bool skiprequest)
{ {
Printf("Clock = %llu\n", clock);
if (clock == 0) S_PlayBonusMusic(); if (clock == 0) S_PlayBonusMusic();
twod->ClearScreen(); twod->ClearScreen();
int currentclock = int(clock * 120 / 1'000'000'000); int currentclock = int(clock * 120 / 1'000'000'000);

View file

@ -166,7 +166,7 @@ void GameInterface::NextLevel(MapRecord* map, int skill)
{ {
ud.m_player_skill = skill + 1; ud.m_player_skill = skill + 1;
int res = enterlevel(map, 0); int res = enterlevel(map, 0);
if (!res) gameaction = ga_startup; if (res) gameaction = ga_startup;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------