From 30e96293cf02ab4225aae9acdd85452139a13b97 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 30 Oct 2020 17:11:40 +0100 Subject: [PATCH] - implemented the game progression interface. --- source/build/include/build.h | 4 -- source/games/whaven/src/items.cpp | 4 +- source/games/whaven/src/main.cpp | 65 +++++++++++++++++++++++++++++++ source/games/whaven/src/wh.h | 7 ++-- source/games/whaven/src/whfx.cpp | 26 ++----------- source/games/whaven/src/whmap.cpp | 12 ------ source/games/whaven/src/whplr.cpp | 2 +- 7 files changed, 73 insertions(+), 47 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index b00bf1be8..0989f3f14 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -839,10 +839,6 @@ int32_t md_undefinemodel(int32_t modelid); int32_t loaddefinitionsfile(const char *fn, bool loadadds = false); -// if loadboard() fails with -2 return, try loadoldboard(). if it fails with -// -2, board is dodgy -int32_t engineLoadBoardV5V6(const char *filename, char fromwhere, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum); - #ifdef USE_OPENGL # include "polymost.h" #endif diff --git a/source/games/whaven/src/items.cpp b/source/games/whaven/src/items.cpp index 314ca1896..20967b08b 100644 --- a/source/games/whaven/src/items.cpp +++ b/source/games/whaven/src/items.cpp @@ -582,9 +582,7 @@ void InitItems() { if (isWh2()) { - startWh2Ending([](bool) { - gameaction = ga_mainmenu; - }); + CompleteLevel(nullptr); return; } plr.treasure[THORNEDSKULL] = 1; diff --git a/source/games/whaven/src/main.cpp b/source/games/whaven/src/main.cpp index 94a2083bd..8c29fca5d 100644 --- a/source/games/whaven/src/main.cpp +++ b/source/games/whaven/src/main.cpp @@ -6,6 +6,8 @@ #include "v_draw.h" #include "menu.h" #include "mmulti.h" +#include "raze_music.h" +#include "statistics.h" BEGIN_WH_NS @@ -338,6 +340,69 @@ void GameInterface::Ticker() r_NoInterpolate = false; } +void GameInterface::LevelCompleted(MapRecord* map, int skill) +{ + if (map) + { + STAT_Update(false); + auto pplr = &player[pyrn]; + auto completion = [=](bool) + { + spritesound(S_CHAINDOOR1, &sprite[pplr->spritenum]); + playertorch = 0; + spritesound(S_WARP, &sprite[pplr->spritenum]); + }; + if (isWh2()) { + showStatisticsScreen(completion); + return; + } + completion(false); + } + else if (!isWh2()) + { + STAT_Update(true); + showVictoryScreen([=](bool) + { + gameaction = ga_mainmenu; + }); + } + else + { + STAT_Update(true); + startWh2Ending([](bool) { + gameaction = ga_mainmenu; + }); + } +} + +void GameInterface::NextLevel(MapRecord* map, int skill) +{ + mapon = map->levelNumber; + currentLevel = map; + difficulty = skill; + nextlevel = true; + prepareboard(currentLevel->fileName); + STAT_NewLevel(currentLevel->labelName); +} + + +void GameInterface::NewGame(MapRecord* map, int skill) +{ + //pNet.ready2send = false; + //game.nNetMode = NetMode.Single; + + mapon = map->levelNumber; + currentLevel = map; + difficulty = skill; + justteleported = false; + nextlevel = false; + Mus_Stop(); + prepareboard(currentLevel->fileName); + STAT_StartNewGame(isWh2() ? "Witchaven2" : "Witchaven", skill); + STAT_NewLevel(currentLevel->labelName); +} + + void GameInterface::MenuSound(EMenuSounds snd) { if (!isWh2()) SND_Sound(85); diff --git a/source/games/whaven/src/wh.h b/source/games/whaven/src/wh.h index 2cf1f96e3..131491d3f 100644 --- a/source/games/whaven/src/wh.h +++ b/source/games/whaven/src/wh.h @@ -273,7 +273,6 @@ void setdelayfunc(int item, int delay); extern boolean nextlevel; -void loadnewlevel(int mapon); void preparesectors(); boolean prepareboard(const char* fname); @@ -543,9 +542,9 @@ struct GameInterface : public ::GameInterface void Ticker() override; const char* GenericCheat(int player, int cheat) override; const char* CheckCheatMode() override; - //void NextLevel(MapRecord* map, int skill) override; - //void NewGame(MapRecord* map, int skill) override; - //void LevelCompleted(MapRecord* map, int skill) override; + void NextLevel(MapRecord* map, int skill) override; + void NewGame(MapRecord* map, int skill) override; + void LevelCompleted(MapRecord* map, int skill) override; //bool DrawAutomapPlayer(int x, int y, int z, int a) override; //int playerKeyMove() override { return 40; } diff --git a/source/games/whaven/src/whfx.cpp b/source/games/whaven/src/whfx.cpp index 62d9198cd..d6163fea0 100644 --- a/source/games/whaven/src/whfx.cpp +++ b/source/games/whaven/src/whfx.cpp @@ -1,6 +1,7 @@ #include "ns.h" #include "wh.h" #include "gamestate.h" +#include "mapinfo.h" BEGIN_WH_NS @@ -461,33 +462,12 @@ void teleporter() { switch (sector[plr.sector].hitag) { case 1: // NEXTLEVEL justteleported = true; - - if(isWh2()) { - auto pplr = &plr; - showStatisticsScreen([=](bool) - { - mapon++; - spritesound(S_CHAINDOOR1, &sprite[pplr->spritenum]); - playertorch = 0; - spritesound(S_WARP, &sprite[pplr->spritenum]); - loadnewlevel(mapon); - }); - break; - } - - mapon++; - spritesound(S_CHAINDOOR1, &sprite[plr.spritenum]); - playertorch = 0; - spritesound(S_WARP, &sprite[plr.spritenum]); - loadnewlevel(mapon); + CompleteLevel(currentLevel); break; case 2: // ENDOFDEMO spritesound(S_THUNDER1, &sprite[plr.spritenum]); justteleported = true; - showVictoryScreen([=](bool) - { - gameaction = ga_mainmenu; - }); + CompleteLevel(nullptr); break; } } else { diff --git a/source/games/whaven/src/whmap.cpp b/source/games/whaven/src/whmap.cpp index 2523e6e05..041b739d8 100644 --- a/source/games/whaven/src/whmap.cpp +++ b/source/games/whaven/src/whmap.cpp @@ -9,18 +9,6 @@ BEGIN_WH_NS boolean nextlevel; -void loadnewlevel(int mapon) { -#if 0 - MapInfo nextmap; - if(gCurrentEpisode != nullptr && (nextmap = gCurrentEpisode.getMap(mapon)) != nullptr) { - boardfilename = nextmap.path; - Console.Println("Entering level " + boardfilename); - nextlevel = true; - gGameScreen.loadboard(boardfilename, nullptr); - } else game.show(); -#endif -} - void preparesectors() { int endwall, j, k = 0, startwall; int dax, day; diff --git a/source/games/whaven/src/whplr.cpp b/source/games/whaven/src/whplr.cpp index 3ba1fbabb..1f8ff4e57 100644 --- a/source/games/whaven/src/whplr.cpp +++ b/source/games/whaven/src/whplr.cpp @@ -23,7 +23,7 @@ int damage_vel, damage_svel, damage_angvel; void viewBackupPlayerLoc( int nPlayer ) { SPRITE& pSprite = sprite[player[nPlayer].spritenum]; - PLOCATION pPLocation = gPrevPlayerLoc[nPlayer]; + PLOCATION& pPLocation = gPrevPlayerLoc[nPlayer]; pPLocation.x = pSprite.x; pPLocation.y = pSprite.y; pPLocation.z = player[nPlayer].z;