- 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
This commit is contained in:
Christoph Oelckers 2019-12-09 00:55:30 +01:00
parent 4ef9ec6708
commit 66218dd074
8 changed files with 47 additions and 25 deletions

View file

@ -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

View file

@ -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

View file

@ -168,6 +168,7 @@ struct GameStats
int kill, tkill;
int secret, tsecret;
int timesecnd;
int frags;
};
struct FGameStartup

View file

@ -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();
}
});

View file

@ -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 };
}

View file

@ -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

View file

@ -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,6 +1521,7 @@ 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

View file

@ -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;
};