- transitioned Exhumed to level change events.

This commit is contained in:
Christoph Oelckers 2020-09-04 21:59:38 +02:00
parent 8114309e89
commit 1eb99f69c2
12 changed files with 110 additions and 173 deletions

View file

@ -66,8 +66,16 @@ void FSavegameManager::LoadGame(FSaveGameNode* node)
{ {
if (gi->LoadGame(node)) if (gi->LoadGame(node))
{ {
// do something here? gamestate = GS_LEVEL;
} }
else
{
I_Error("%s: Failed to load savegame", node->Filename.GetChars());
}
}
else
{
I_Error("%s: Failed to open savegame", node->Filename.GetChars());
} }
} }

View file

@ -28,6 +28,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "version.h" #include "version.h"
#include "raze_sound.h" #include "raze_sound.h"
#include "gamestate.h" #include "gamestate.h"
#include "mapinfo.h"
#include "gamecontrol.h"
#include "menu/menu.h" // to override the local menu.h #include "menu/menu.h" // to override the local menu.h
@ -151,9 +153,7 @@ void GameInterface::MenuSound(EMenuSounds snd)
void GameInterface::QuitToTitle() void GameInterface::QuitToTitle()
{ {
M_StartControlPanel(false); gameaction = ga_mainmenu;
M_SetMenu(NAME_Mainmenu);
gamestate = GS_MENUSCREEN;
} }
void GameInterface::MenuClosed() void GameInterface::MenuClosed()
@ -164,7 +164,8 @@ void GameInterface::MenuClosed()
void GameInterface::StartGame(FNewGameStartup& gs) void GameInterface::StartGame(FNewGameStartup& gs)
{ {
GameAction = gs.Episode; // 0 is training, 1 is the regular game auto map = FindMapByLevelNum(gs.Episode);
DeferedStartGame(map, 0); // 0 is training, 1 is the regular game - the game does not have skill levels.
} }
FSavegameInfo GameInterface::GetSaveSig() FSavegameInfo GameInterface::GetSaveSig()

View file

@ -63,7 +63,7 @@ int32_t registerosdcommands(void);
void InitFonts(); void InitFonts();
void InitCheats(); void InitCheats();
int EndLevel = false; int EndLevel = 0;
InputPacket localInput; InputPacket localInput;
@ -260,8 +260,6 @@ double calc_smoothratio()
return I_GetTimeFrac() * MaxSmoothRatio; return I_GetTimeFrac() * MaxSmoothRatio;
} }
void CheckProgression();
void GameMove(void) void GameMove(void)
{ {
FixPalette(); FixPalette();
@ -336,7 +334,12 @@ static int SelectAltWeapon(int weap2)
void GameInterface::Ticker() void GameInterface::Ticker()
{ {
if (!paused)
if (paused)
{
r_NoInterpolate = true;
}
else if (EndLevel == 0)
{ {
nPlayerDAng += localInput.q16avel; nPlayerDAng += localInput.q16avel;
inita &= kAngleMask; inita &= kAngleMask;
@ -453,8 +456,17 @@ void GameInterface::Ticker()
GameMove(); GameMove();
r_NoInterpolate = false; r_NoInterpolate = false;
} }
else r_NoInterpolate = true; else
CheckProgression(); // todo: Get rid of this. {
// Wait for the end of level sound to play out, but stop updating the playsim.
EndLevel--;
r_NoInterpolate = false;
if (EndLevel == 0)
{
auto map = currentLevel->levelNumber == 20? nullptr : FindMapByLevelNum(currentLevel->levelNumber+1); // todo: Use the map record for progression
CompleteLevel(map);
}
}
} }
void ExitGame() void ExitGame()

View file

@ -100,7 +100,6 @@ extern int32_t g_noSetup;
extern char sHollyStr[]; extern char sHollyStr[];
extern int selectedlevelnew; extern int selectedlevelnew;
extern int GameAction;
extern int nNetPlayerCount; extern int nNetPlayerCount;
@ -254,6 +253,10 @@ struct GameInterface : ::GameInterface
void GetInput(InputPacket* packet) override; void GetInput(InputPacket* packet) override;
void Startup() override; void Startup() override;
const char* GenericCheat(int player, int cheat) override; const char* GenericCheat(int player, int cheat) override;
void NewGame(MapRecord *map, int skill) override;
void LevelCompleted(MapRecord *map, int skill) override;
void NextLevel(MapRecord *map, int skill) override;
::GameStats getStats() override; ::GameStats getStats() override;
}; };

View file

@ -50,13 +50,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_PS_NS BEGIN_PS_NS
void CheckProgression();
short nBestLevel; short nBestLevel;
static int32_t nonsharedtimer; static int32_t nonsharedtimer;
int GameAction=-1;
extern uint8_t nCinemaSeen; extern uint8_t nCinemaSeen;
void RunCinemaScene(int num); void RunCinemaScene(int num);
@ -65,14 +61,8 @@ void DrawClock();
double calc_smoothratio(); double calc_smoothratio();
void DoTitle(CompletionFunc completion); void DoTitle(CompletionFunc completion);
static int FinishLevel(TArray<JobDesc> &jobs) static void FinishLevel(int lnum, TArray<JobDesc> &jobs)
{ {
int lnum = currentLevel->levelNumber;
if (lnum > nBestLevel) {
nBestLevel = lnum - 1;
}
StopAllSounds(); StopAllSounds();
bCamera = false; bCamera = false;
@ -81,7 +71,7 @@ static int FinishLevel(TArray<JobDesc> &jobs)
STAT_Update(lnum == kMap20); STAT_Update(lnum == kMap20);
if (lnum != kMap20) if (lnum != kMap20)
{ {
if (EndLevel != 2 && !netgame) if (EndLevel == 13 && !netgame)
{ {
// There's really no choice but to enter an active wait loop here to make the sound play out. // There's really no choice but to enter an active wait loop here to make the sound play out.
PlayLocalSound(StaticSound[59], 0, true, CHANF_UI); PlayLocalSound(StaticSound[59], 0, true, CHANF_UI);
@ -97,7 +87,6 @@ static int FinishLevel(TArray<JobDesc> &jobs)
else nPlayerLives[0] = 0; else nPlayerLives[0] = 0;
DoAfterCinemaScene(lnum, jobs); DoAfterCinemaScene(lnum, jobs);
return lnum == kMap20? -1 : lnum + 1;
} }
@ -145,7 +134,6 @@ void GameInterface::Render()
// //
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void CheckProgression();
void GameInterface::DrawBackground() void GameInterface::DrawBackground()
{ {
@ -161,7 +149,6 @@ void GameInterface::DrawBackground()
// draw the fire urn/lamp thingies // draw the fire urn/lamp thingies
DrawRel(kTile3512 + dword_9AB5F, 50, 150, 32); DrawRel(kTile3512 + dword_9AB5F, 50, 150, 32);
DrawRel(kTile3512 + ((dword_9AB5F + 2) & 3), 270, 150, 32); DrawRel(kTile3512 + ((dword_9AB5F + 2) & 3), 270, 150, 32);
CheckProgression();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -170,78 +157,73 @@ void GameInterface::DrawBackground()
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void CheckProgression() static void Intermission(MapRecord *from_map, MapRecord *to_map)
{ {
TArray<JobDesc> jobs; TArray<JobDesc> jobs;
bool startlevel = false;
int mylevelnew = -1;
if (GameAction >= 0) if (to_map && to_map->levelNumber != 0)
{ {
if (GameAction < 1000) nBestLevel = to_map->levelNumber - 1;
{ FinishLevel(to_map->levelNumber, jobs);
// start a new game on the given level }
currentLevel = nullptr;
mylevelnew = GameAction; if (to_map->levelNumber > -1 && to_map->levelNumber < kMap20)
currentLevel = FindMapByLevelNum(mylevelnew); {
GameAction = -1; // start a new game at the given level
InitNewGame(); if (!nNetPlayerCount && to_map->levelNumber > 0)
if (mylevelnew > 0) STAT_StartNewGame("Exhumed", 1); {
if (mylevelnew != 0) nBestLevel = mylevelnew - 1; showmap(from_map? from_map->levelNumber : -1, to_map->levelNumber, nBestLevel, jobs);
} }
else else
{ jobs.Push({ Create<DScreenJob>() }); // we need something in here even in the multiplayer case.
// A savegame was loaded. Just start the level without any further actions. }
GameAction = -1; if (jobs.Size() > 0)
gamestate = GS_LEVEL; {
return; RunScreenJob(jobs.Data(), jobs.Size(), [=](bool)
} {
} if (!to_map) gameaction = ga_startup; // this was the end of the game
else if (EndLevel) else
{ {
if (currentLevel->levelNumber == 0) startmainmenu(); if (to_map->levelNumber != selectedlevelnew)
else mylevelnew = FinishLevel(jobs); {
EndLevel = false; // User can switch destination on the scrolling map.
} g_nextmap = FindMapByLevelNum(selectedlevelnew);
if (mylevelnew > -1 && mylevelnew < kMap20) STAT_Cancel();
{ }
startlevel = true; gameaction = ga_nextlevel;
// start a new game at the given level
if (!nNetPlayerCount && mylevelnew > 0)
{
showmap(currentLevel? currentLevel->levelNumber : -1, mylevelnew, nBestLevel, jobs);
}
else
jobs.Push({ Create<DScreenJob>() }); // we need something in here even in the multiplayer case.
}
if (jobs.Size() > 0)
{
selectedlevelnew = mylevelnew;
RunScreenJob(jobs.Data(), jobs.Size(), [=](bool)
{
if (!startlevel) gamestate = GS_STARTUP;
else
{
gamestate = GS_LEVEL;
InitLevel(selectedlevelnew); }
#if 0 });
// this would be the place to autosave upon level start }
if (!bInDemo && selectedlevelnew > nBestLevel && selectedlevelnew != 0 && selectedlevelnew <= kMap20) {
menu_GameSave(SavePosition); }
}
#endif
if (selectedlevelnew > nBestLevel)
{
nBestLevel = selectedlevelnew;
}
if (selectedlevelnew == 11) nCinemaSeen |= 2; void GameInterface::NextLevel(MapRecord *map, int skill)
if (mylevelnew != selectedlevelnew) STAT_Cancel(); {
else STAT_NewLevel(currentLevel->labelName); InitLevel(map->levelNumber);
}
}); if (map->levelNumber > nBestLevel)
} {
nBestLevel = selectedlevelnew;
}
if (map->levelNumber == 11) nCinemaSeen |= 2;
STAT_NewLevel(currentLevel->labelName);
}
void GameInterface::NewGame(MapRecord *map, int skill)
{
// start a new game on the given level
InitNewGame();
if (map->levelNumber == 1) STAT_StartNewGame("Exhumed", 1);
Intermission(nullptr, map);
}
void GameInterface::LevelCompleted(MapRecord *map, int skill)
{
if (currentLevel->levelNumber == 0) startmainmenu();
else Intermission(currentLevel, map);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -253,14 +235,13 @@ void CheckProgression()
void GameInterface::Startup() void GameInterface::Startup()
{ {
resettiming(); resettiming();
GameAction = -1; EndLevel = 0;
EndLevel = false;
if (userConfig.CommandMap.IsNotEmpty()) if (userConfig.CommandMap.IsNotEmpty())
{ {
/* /*
auto map = FindMapByName(userConfig.CommandMap); auto map = FindMapByName(userConfig.CommandMap);
if (map) GameAction = map->levelNumber; if (map) DeferedStartMap(map, 0);
userConfig.CommandMap = ""; userConfig.CommandMap = "";
goto again; goto again;
*/ */
@ -276,8 +257,7 @@ void GameInterface::Startup()
void GameInterface::ErrorCleanup() void GameInterface::ErrorCleanup()
{ {
// Clear all progression sensitive variables here. // Clear all progression sensitive variables here.
GameAction = -1; EndLevel = 0;
EndLevel = false;
} }
END_PS_NS END_PS_NS

View file

@ -173,7 +173,7 @@ uint8_t LoadLevel(int nMap)
return true; return true;
} }
void InitLevel(int level) void InitLevel(int level) // todo: use a map record
{ {
StopCD(); StopCD();
if (!LoadLevel(level)) { if (!LoadLevel(level)) {
@ -187,7 +187,7 @@ void InitLevel(int level)
RestartPlayer(i); RestartPlayer(i);
InitPlayerKeys(i); InitPlayerKeys(i);
} }
EndLevel = 0;
lastfps = 0; lastfps = 0;
InitStatus(); InitStatus();
ResetView(); ResetView();

View file

@ -1544,7 +1544,7 @@ void DoFinale()
} }
else if (nFinaleStage == 3 && leveltime >= nextstage) else if (nFinaleStage == 3 && leveltime >= nextstage)
{ {
EndLevel = true; EndLevel = 13;
} }
} }
else else

View file

@ -35,63 +35,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_PS_NS BEGIN_PS_NS
static int osdcmd_map(CCmdFuncPtr parm)
{
if (parm->numparms != 1)
{
return CCMD_SHOWHELP;
}
FString mapname = parm->parms[0];
FString mapfilename = mapname;
DefaultExtension(mapfilename, ".map");
if (!fileSystem.FileExists(mapfilename))
{
Printf(TEXTCOLOR_RED "map: file \"%s\" not found.\n", mapfilename.GetChars());
return CCMD_OK;
}
// Check if the map is already defined.
auto map = FindMapByName(mapname);
if (map)
{
GameAction = map->levelNumber;
}
return CCMD_OK;
}
static int osdcmd_changelevel(CCmdFuncPtr parm)
{
char* p;
if (parm->numparms != 1) return CCMD_SHOWHELP;
int nLevel = strtol(parm->parms[0], &p, 10);
if (p[0]) return CCMD_SHOWHELP;
if (nLevel < 0) return CCMD_SHOWHELP;
int nMaxLevels;
if (!ISDEMOVER) {
nMaxLevels = 32;
}
else {
nMaxLevels = 4;
}
if (nLevel > nMaxLevels)
{
Printf("changelevel: invalid level number\n");
return CCMD_SHOWHELP;
}
GameAction = nLevel;
return CCMD_OK;
}
static int osdcmd_warptocoords(CCmdFuncPtr parm) static int osdcmd_warptocoords(CCmdFuncPtr parm)
{ {
if (parm->numparms < 3 || parm->numparms > 5) if (parm->numparms < 3 || parm->numparms > 5)
@ -117,12 +60,6 @@ static int osdcmd_warptocoords(CCmdFuncPtr parm)
return CCMD_OK; return CCMD_OK;
} }
static int osdcmd_exitmap(CCmdFuncPtr parm)
{
EndLevel = true;
return CCMD_OK;
}
static int osdcmd_doors(CCmdFuncPtr parm) static int osdcmd_doors(CCmdFuncPtr parm)
{ {
for (int i = 0; i < kMaxChannels; i++) for (int i = 0; i < kMaxChannels; i++)
@ -195,9 +132,6 @@ static int osdcmd_noop(CCmdFuncPtr parm)
int32_t registerosdcommands(void) int32_t registerosdcommands(void)
{ {
//if (VOLUMEONE) //if (VOLUMEONE)
C_RegisterFunction("levelwarp","levelwarp <level>: warps to the given level", osdcmd_changelevel);
C_RegisterFunction("map","map <mapname>: loads the given map", osdcmd_map);
C_RegisterFunction("exitmap", "exits current map", osdcmd_exitmap);
C_RegisterFunction("doors", "opens/closes doors", osdcmd_doors); C_RegisterFunction("doors", "opens/closes doors", osdcmd_doors);
C_RegisterFunction("spawn","spawn <creaturetype>: spawns a creature",osdcmd_spawn); C_RegisterFunction("spawn","spawn <creaturetype>: spawns a creature",osdcmd_spawn);
C_RegisterFunction("warptocoords","warptocoords [x] [y] [z] [ang] (optional) [horiz] (optional): warps the player to the specified coordinates",osdcmd_warptocoords); C_RegisterFunction("warptocoords","warptocoords [x] [y] [z] [ang] (optional) [horiz] (optional): warps the player to the specified coordinates",osdcmd_warptocoords);

View file

@ -1065,7 +1065,7 @@ void FuncPlayer(int a, int nDamage, int nRun)
} }
else else
{ {
EndLevel = true; EndLevel = 13;
} }
return; return;
@ -2462,7 +2462,7 @@ do_default_b:
{ {
if (!bInDemo) if (!bInDemo)
{ {
EndLevel = true; EndLevel = 13;
} }
DestroyItemAnim(nValB); DestroyItemAnim(nValB);

View file

@ -490,7 +490,7 @@ int DoSpiritHead()
{ {
if (!CDplaying()) if (!CDplaying())
{ {
EndLevel = 2; EndLevel = 1;
} }
} }
} }

View file

@ -60,7 +60,6 @@ bool GameInterface::LoadGame(FSaveGameNode* sv)
pSky->yscale = 65536; pSky->yscale = 65536;
parallaxtype = 2; parallaxtype = 2;
g_visibility = 2048; g_visibility = 2048;
GameAction = 1000;
if (currentLevel->levelNumber > 15) if (currentLevel->levelNumber > 15)
{ {

View file

@ -436,7 +436,7 @@ void DrawView(double smoothRatio, bool sceneonly)
if ((bSubTitles && !subtitleOverlay.AdvanceCinemaText(myclock)) || inputState.CheckAllInput()) if ((bSubTitles && !subtitleOverlay.AdvanceCinemaText(myclock)) || inputState.CheckAllInput())
{ {
inputState.ClearAllInput(); inputState.ClearAllInput();
EndLevel = 2; EndLevel = 1;
if (CDplaying()) { if (CDplaying()) {
fadecdaudio(); fadecdaudio();