- hooked up the statistics code with EDuke and RedNukem frontends.

Not sure about the end of game conditions, I wasn't able to test that part yet.
This commit is contained in:
Christoph Oelckers 2019-11-12 22:45:11 +01:00
parent 74ed8fd1d9
commit 6ccef7201e
6 changed files with 31 additions and 5 deletions

View File

@ -397,6 +397,7 @@ static void StoreLevelStats()
void STAT_Update(bool endofgame) void STAT_Update(bool endofgame)
{ {
if (*StartEpisode == 0) return;
const char* fn = "?"; const char* fn = "?";
// record the current level's stats. // record the current level's stats.
StoreLevelStats(); StoreLevelStats();
@ -439,9 +440,16 @@ void STAT_Update(bool endofgame)
LevelStatEntry(es, lsection, infostring, LevelData[i].leveltime); LevelStatEntry(es, lsection, infostring, LevelData[i].leveltime);
} }
SaveStatistics(statfile, EpisodeStatistics); SaveStatistics(statfile, EpisodeStatistics);
LevelData.Clear();
*StartEpisode = *LevelName = 0;
} }
} }
void STAT_Cancel()
{
LevelData.Clear();
*StartEpisode = *LevelName = 0;
}
//========================================================================== //==========================================================================
// //

View File

@ -0,0 +1,7 @@
#pragma once
void STAT_StartNewGame(const char *episode, int skill);
void STAT_NewLevel(const char* mapname);
void STAT_Update(bool endofgame);
void STAT_Cancel();

View File

@ -44,7 +44,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "gameconfigfile.h" #include "gameconfigfile.h"
#include "printf.h" #include "printf.h"
#include "m_argv.h" #include "m_argv.h"
#include "filesystem/filesystem.h" #include "filesystem.h"
#include "statistics.h"
// Uncomment to prevent anything except mirrors from drawing. It is sensible to // Uncomment to prevent anything except mirrors from drawing. It is sensible to
// also uncomment ENGINE_CLEAR_SCREEN in build/src/engine_priv.h. // also uncomment ENGINE_CLEAR_SCREEN in build/src/engine_priv.h.
@ -6014,6 +6015,7 @@ static int G_EndOfLevel(void)
{ {
auto &p = *g_player[myconnectindex].ps; auto &p = *g_player[myconnectindex].ps;
STAT_Update(ud.eog);
P_SetGamePalette(&p, BASEPAL, 0); P_SetGamePalette(&p, BASEPAL, 0);
P_UpdateScreenPal(&p); P_UpdateScreenPal(&p);

View File

@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "duke3d.h" #include "duke3d.h"
#include "menus.h" #include "menus.h"
#include "savegame.h" #include "savegame.h"
#include "statistics.h"
BEGIN_DUKE_NS BEGIN_DUKE_NS
static uint8_t precachehightile[2][(MAXTILES+7)>>3]; static uint8_t precachehightile[2][(MAXTILES+7)>>3];
@ -1337,6 +1338,7 @@ void G_NewGame(int volumeNum, int levelNum, int skillNum)
ud.secretlevel = 0; ud.secretlevel = 0;
ud.skill_voice = -1; ud.skill_voice = -1;
ud.volume_number = volumeNum; ud.volume_number = volumeNum;
STAT_StartNewGame(g_volumeNames[volumeNum], skillNum);
g_lastAutoSaveArbitraryID = -1; g_lastAutoSaveArbitraryID = -1;
g_lastautosave.reset(); g_lastautosave.reset();
@ -1853,7 +1855,7 @@ int G_EnterLevel(int gameMode)
OSD_Printf(OSD_ERROR "Map \"%s\" not found or invalid map version!\n", boardfilename); OSD_Printf(OSD_ERROR "Map \"%s\" not found or invalid map version!\n", boardfilename);
return 1; return 1;
} }
STAT_NewLevel(boardfilename);
G_LoadMapHack(levelName, boardfilename); G_LoadMapHack(levelName, boardfilename);
G_SetupFilenameBasedMusic(levelName, boardfilename); G_SetupFilenameBasedMusic(levelName, boardfilename);
} }
@ -1864,6 +1866,7 @@ int G_EnterLevel(int gameMode)
} }
else else
{ {
STAT_NewLevel(m.filename);
G_LoadMapHack(levelName, m.filename); G_LoadMapHack(levelName, m.filename);
} }

View File

@ -45,6 +45,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "printf.h" #include "printf.h"
#include "m_argv.h" #include "m_argv.h"
#include "filesystem/filesystem.h" #include "filesystem/filesystem.h"
#include "statistics.h"
// Uncomment to prevent anything except mirrors from drawing. It is sensible to // Uncomment to prevent anything except mirrors from drawing. It is sensible to
// also uncomment ENGINE_CLEAR_SCREEN in build/src/engine_priv.h. // also uncomment ENGINE_CLEAR_SCREEN in build/src/engine_priv.h.
@ -7434,6 +7435,7 @@ void G_BackToMenu(void)
static int G_EndOfLevel(void) static int G_EndOfLevel(void)
{ {
STAT_Update(ud.eog);
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 0); P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 0);
P_UpdateScreenPal(g_player[myconnectindex].ps); P_UpdateScreenPal(g_player[myconnectindex].ps);

View File

@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "demo.h" #include "demo.h"
#include "savegame.h" #include "savegame.h"
#include "cmdline.h" #include "cmdline.h"
#include "statistics.h"
BEGIN_RR_NS BEGIN_RR_NS
@ -1899,6 +1900,7 @@ void G_NewGame(int volumeNum, int levelNum, int skillNum)
ud.player_skill = skillNum; ud.player_skill = skillNum;
ud.secretlevel = 0; ud.secretlevel = 0;
ud.from_bonus = 0; ud.from_bonus = 0;
STAT_StartNewGame(g_volumeNames[volumeNum], skillNum);
ud.last_level = -1; ud.last_level = -1;
g_lastAutoSaveArbitraryID = -1; g_lastAutoSaveArbitraryID = -1;
@ -2398,6 +2400,7 @@ int G_EnterLevel(int gameMode)
return 1; return 1;
} }
STAT_NewLevel(boardfilename);
G_LoadMapHack(levelName, boardfilename); G_LoadMapHack(levelName, boardfilename);
G_SetupFilenameBasedMusic(levelName, boardfilename, m_level_number); G_SetupFilenameBasedMusic(levelName, boardfilename, m_level_number);
} }
@ -2408,6 +2411,7 @@ int G_EnterLevel(int gameMode)
} }
else else
{ {
STAT_NewLevel(g_mapInfo[mii].filename);
G_LoadMapHack(levelName, g_mapInfo[mii].filename); G_LoadMapHack(levelName, g_mapInfo[mii].filename);
} }