From 66218dd074b3002e26b719e6fe2f1efe864d0ef2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 9 Dec 2019 00:55:30 +0100 Subject: [PATCH] - connect SW with statistics code and added missing function for Blood # Conflicts: # source/blood/src/blood.h # source/common/menu/messagebox.cpp # source/sw/src/game.cpp # source/sw/src/game.h --- source/blood/src/blood.h | 1 + source/blood/src/view.cpp | 5 +++ source/build/include/baselayer.h | 1 + source/common/menu/messagebox.cpp | 2 ++ source/duke3d/src/screens.cpp | 2 +- source/rr/src/screens.cpp | 2 +- source/sw/src/game.cpp | 58 +++++++++++++++++++------------ source/sw/src/game.h | 1 + 8 files changed, 47 insertions(+), 25 deletions(-) diff --git a/source/blood/src/blood.h b/source/blood/src/blood.h index 0761bb81a..164d56413 100644 --- a/source/blood/src/blood.h +++ b/source/blood/src/blood.h @@ -101,6 +101,7 @@ struct GameInterface : ::GameInterface void DrawCenteredTextScreen(const DVector2& origin, const char* text, int position, bool bg); void QuitToTitle() override; + GameStats getStats() override; }; END_BLD_NS diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index 6044a2176..668319b14 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -1164,6 +1164,11 @@ void viewDrawStats(PLAYER *pPlayer, int x, int y) viewDrawText(3, buffer, x, y, 20, 0, 0, true, 256); } +GameStats GameInterface::getStats() +{ + return { gKillMgr.at4, gKillMgr.at0, gSecretMgr.at8, gSecretMgr.at0, gLevelTime / kTicsPerSec, gPlayer[myconnectindex].fragCount }; +} + #define kSBarNumberHealth 9220 #define kSBarNumberAmmo 9230 #define kSBarNumberInv 9240 diff --git a/source/build/include/baselayer.h b/source/build/include/baselayer.h index 851b7289e..979f2e95f 100644 --- a/source/build/include/baselayer.h +++ b/source/build/include/baselayer.h @@ -168,6 +168,7 @@ struct GameStats int kill, tkill; int secret, tsecret; int timesecnd; + int frags; }; struct FGameStartup diff --git a/source/common/menu/messagebox.cpp b/source/common/menu/messagebox.cpp index 5fe3c8248..134358930 100644 --- a/source/common/menu/messagebox.cpp +++ b/source/common/menu/messagebox.cpp @@ -39,6 +39,7 @@ #include "v_draw.h" #include "gstrings.h" #include "c_dispatch.h" +#include "statistics.h" #include "v_2ddrawer.h" extern FSaveGameNode *quickSaveSlot; @@ -407,6 +408,7 @@ CCMD (menu_endgame) { if (res) { + STAT_Cancel(); gi->QuitToTitle(); } }); diff --git a/source/duke3d/src/screens.cpp b/source/duke3d/src/screens.cpp index df1cd1f4a..5dbdac236 100644 --- a/source/duke3d/src/screens.cpp +++ b/source/duke3d/src/screens.cpp @@ -1153,7 +1153,7 @@ void G_DisplayRest(int32_t smoothratio) GameStats GameInterface::getStats() { DukePlayer_t* p = g_player[myconnectindex].ps; - return { p->actors_killed, p->max_actors_killed, p->secret_rooms, p->max_secret_rooms, p->player_par / REALGAMETICSPERSEC }; + return { p->actors_killed, p->max_actors_killed, p->secret_rooms, p->max_secret_rooms, p->player_par / REALGAMETICSPERSEC, p->frag }; } diff --git a/source/rr/src/screens.cpp b/source/rr/src/screens.cpp index 769b26a2a..409da64aa 100644 --- a/source/rr/src/screens.cpp +++ b/source/rr/src/screens.cpp @@ -755,7 +755,7 @@ FString GameInterface::statFPS() GameStats GameInterface::getStats() { DukePlayer_t* p = g_player[myconnectindex].ps; - return { p->actors_killed, p->max_actors_killed, p->secret_rooms, p->max_secret_rooms, p->player_par / REALGAMETICSPERSEC }; + return { p->actors_killed, p->max_actors_killed, p->secret_rooms, p->max_secret_rooms, p->player_par / REALGAMETICSPERSEC, p->frag }; } #undef FPS_COLOR diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index 5214778ee..9fd7f7b56 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -97,6 +97,7 @@ Things required to make savegames work: #include "debugbreak.h" #include "menu/menu.h" #include "z_music.h" +#include "statistics.h" //#include "crc32.h" @@ -644,24 +645,16 @@ void TerminateGame(void) } -void LoadLevel(const char *filename) +bool LoadLevel(const char *filename) { - int pos; - if (engineLoadBoard(filename, SW_SHAREWARE ? 1 : 0, (vec3_t *)&Player[0], &Player[0].pang, &Player[0].cursectnum) == -1) { TerminateGame(); -#ifdef RENDERTYPEWIN - { - char msg[256]; - Bsnprintf(msg, 256, "Level not found: %s", filename); - wm_msgbox(apptitle, msg); - } -#else - printf("Level Not Found: %s\n", filename); -#endif - exit(0); - } + Printf("Level not found: %s", filename); + return false; + } + STAT_NewLevel(filename); + return true; } void LoadDemoRun(void) @@ -808,7 +801,7 @@ static void SW_FatalEngineError(void) I_Error("There was a problem initialising the Build engine: %s", engineerrstr); } -void InitGame() +bool InitGame() { extern int MovesPerPacket; //void *ReserveMem=NULL; @@ -945,7 +938,7 @@ void InitGame() if (UserMapName[0] == '\0') { AnimateCacheCursor(); - LoadLevel("$dozer.map"); + if (!LoadLevel("$dozer.map")) return false AnimateCacheCursor(); SetupPreCache(); DoTheCache(); @@ -953,7 +946,7 @@ void InitGame() else { AnimateCacheCursor(); - LoadLevel(UserMapName); + if (!LoadLevel(UserMapName)) return false; AnimateCacheCursor(); SetupPreCache(); DoTheCache(); @@ -966,6 +959,7 @@ void InitGame() COVERsetbrightness(0, &palette_data[0][0]); InitFX(); // JBF: do it down here so we get a hold of the window handle + return true; } @@ -1231,7 +1225,12 @@ InitLevel(void) if (!DemoMode && !DemoInitOnce) DemoPlaySetup(); - LoadLevel(LevelName); + if (!LoadLevel(LevelName)) + { + NewGame = false; + return; + } + STAT_NewLevel(LevelName); if (Bstrcasecmp(CacheLastLevel, LevelName) != 0) // clears gotpic and does some bit setting @@ -1488,6 +1487,7 @@ void NewLevel(void) FX_SetVolume(0); // Shut the hell up while game is loading! InitLevel(); RunLevel(); + STAT_Update(false); if (!QuitFlag) { @@ -1512,6 +1512,7 @@ void NewLevel(void) { PlayTheme(); MenuLevel(); + STAT_Update(true); } } else @@ -1520,7 +1521,8 @@ void NewLevel(void) { PlayTheme(); MenuLevel(); - } + STAT_Update(true); + } } FinishAnim = 0; } @@ -2092,13 +2094,15 @@ int BonusGrabSound(short SpriteNum) return 0; } +extern SWBOOL FinishedLevel; +extern int PlayClock; +extern short LevelSecrets; +extern short TotalKillable; + void BonusScreen(PLAYERp pp) { int minutes,seconds,second_tics; - extern SWBOOL FinishedLevel; - extern int PlayClock; - extern short LevelSecrets; - extern short TotalKillable; + short w,h; short pic,limit; int zero=0; @@ -4329,4 +4333,12 @@ void Saveable_Init_Dynamic() } +GameStats GameInterface::getStats() +{ + PLAYERp pp = Player + myconnectindex; + return { pp->Kills, TotalKillable, pp->SecretsFound, LevelSecrets, PlayClock / 120, 0 }; +} + + + END_SW_NS diff --git a/source/sw/src/game.h b/source/sw/src/game.h index 80bb812b7..17cbc12ef 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -2385,6 +2385,7 @@ struct GameInterface : ::GameInterface void DoPrintMessage(int prio, const char* text) override; void SetAmbience(bool on) override { if (on) StartAmbientSound(); else StopAmbientSound(); } + GameStats getStats() override; };