- removed the Blood demo code as it won't be usable in this form anyway.

This commit is contained in:
Christoph Oelckers 2020-07-28 00:01:16 +02:00
parent 74c4bbc0e0
commit 92d94543e5
10 changed files with 19 additions and 1028 deletions

View file

@ -32,7 +32,6 @@ set( PCH_SOURCES
src/controls.cpp
src/credits.cpp
src/db.cpp
src/demo.cpp
src/dude.cpp
src/endgame.cpp
src/eventq.cpp

View file

@ -35,7 +35,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "choke.h"
#include "controls.h"
#include "credits.h"
#include "demo.h"
#include "dude.h"
#include "endgame.h"
#include "eventq.h"
@ -346,8 +345,6 @@ void PreloadTiles(void)
void PreloadCache(void)
{
if (gDemo.at1)
return;
PreloadTiles();
ClockTicks clock = totalclock;
int cnt = 0;
@ -440,10 +437,7 @@ static void drawLoadingScreen(void)
char buffer[80];
if (gGameOptions.nGameType == 0)
{
if (gDemo.at1)
strcpy(buffer, GStrings("TXTB_LDEMO"));
else
strcpy(buffer, GStrings("TXTB_LLEVEL"));
strcpy(buffer, GStrings("TXTB_LLEVEL"));
}
else
strcpy(buffer, GStrings(FStringf("TXTB_NETGT%d", gGameOptions.nGameType)));
@ -457,8 +451,6 @@ void StartLevel(GAMEOPTIONS *gameOptions)
gInput = {};
gStartNewGame = 0;
ready2send = 0;
if (gDemo.at0 && gGameStarted)
gDemo.Close();
netWaitForEveryone(0);
if (gGameOptions.nGameType == 0)
{
@ -467,7 +459,7 @@ void StartLevel(GAMEOPTIONS *gameOptions)
if (gEpisodeInfo[gGameOptions.nEpisode].cutALevel == gGameOptions.nLevel
&& gEpisodeInfo[gGameOptions.nEpisode].at8f08)
gGameOptions.uGameFlags |= 4;
if ((gGameOptions.uGameFlags&4) && gDemo.at1 == 0)
if ((gGameOptions.uGameFlags&4))
levelPlayIntroScene(gGameOptions.nEpisode);
///////
@ -506,7 +498,7 @@ void StartLevel(GAMEOPTIONS *gameOptions)
gHealthTemp[i] = xsprite[gPlayer[i].pSprite->extra].health;
}
}
bVanilla = gDemo.at1 && gDemo.m_bLegacy;
bVanilla = false;
enginecompatibility_mode = ENGINECOMPATIBILITY_19960925;//bVanilla;
memset(xsprite,0,sizeof(xsprite));
memset(sprite,0,kMaxSprites*sizeof(spritetype));
@ -625,8 +617,7 @@ void StartLevel(GAMEOPTIONS *gameOptions)
sub_79760();
gFrame = 0;
gChokeCounter = 0;
if (!gDemo.at1)
M_ClearMenus();
M_ClearMenus();
levelTryPlayMusicOrNothing(gGameOptions.nEpisode, gGameOptions.nLevel);
// viewSetMessage("");
viewSetErrorMessage("");
@ -642,8 +633,6 @@ void StartLevel(GAMEOPTIONS *gameOptions)
void StartNetworkLevel(void)
{
if (gDemo.at0)
gDemo.Close();
if (!(gGameOptions.uGameFlags&1))
{
gGameOptions.nEpisode = gPacketStartGame.episodeId;
@ -803,12 +792,9 @@ void ProcessFrame(void)
}
}
viewClearInterpolations();
if (!gDemo.at1)
{
if (paused || gEndGameMgr.at0 || (gGameOptions.nGameType == 0 && M_Active()))
return;
if (gDemo.at0)
gDemo.Write(gFifoInput[(gNetFifoTail-1)&255]);
}
for (int i = connecthead; i >= 0; i = connectpoint2[i])
{
@ -854,8 +840,6 @@ void ProcessFrame(void)
netMasterUpdate();
}
}
if (gDemo.at0)
gDemo.Close();
Mus_Fade(4000);
seqKillAll();
if (gGameOptions.uGameFlags&2)
@ -885,18 +869,7 @@ void ProcessFrame(void)
void ParseOptions(void)
{
#if 0
if (bAddUserMap)
{
char zNode[BMAX_PATH];
char zDir[BMAX_PATH];
char zFName[BMAX_PATH];
_splitpath(gUserMapFilename, zNode, zDir, zFName, NULL);
strcpy(g_modDir, zNode);
strcat(g_modDir, zDir);
strcpy(gUserMapFilename, zFName);
}
#endif
}
void ClockStrobe()
@ -1016,8 +989,6 @@ int GameInterface::app_main()
WeaponInit();
LoadSaveSetup();
LoadSavedInfo();
gDemo.LoadDemoInfo();
Printf("There are %d demo(s) in the loop\n", gDemo.at59ef);
Printf("Loading control setup\n");
ctrlInit();
timerInit(120);
@ -1063,22 +1034,12 @@ RESTART:
goto RESTART;
}
UpdateNetworkMenus();
#if 0
if (!gDemo.at0 && gDemo.at59ef > 0 && gGameOptions.nGameType == 0 && !bNoDemo && demo_playloop)
gDemo.SetupPlayback(NULL);
#endif
gQuitGame = 0;
gRestartGame = 0;
if (gGameOptions.nGameType > 0)
{
inputState.ClearAllInput();
}
#if 0
else if (gDemo.at1 && !bAddUserMap && !bNoDemo && demo_playloop)
gDemo.Playback();
#endif
if (gDemo.at59ef > 0)
M_ClearMenus();
if (!bAddUserMap && !gGameStarted)
{
M_StartControlPanel(false);
@ -1199,8 +1160,6 @@ RESTART:
}
}
ready2send = 0;
if (gDemo.at0)
gDemo.Close();
if (gRestartGame)
{
Mus_Stop();
@ -1226,10 +1185,6 @@ RESTART:
#endif
if (gGameOptions.nGameType != 0)
{
#if 0
if (!gDemo.at0 && gDemo.at59ef > 0 && gGameOptions.nGameType == 0 && !bNoDemo && demo_playloop)
gDemo.NextDemo();
#endif
videoSetViewableArea(0,0,xdim-1,ydim-1);
playvideo = !bQuickStart;
}
@ -1510,155 +1465,6 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass)
}
break;
#if 0
case T_CUTSCENE:
{
char *fileName = NULL;
scriptfile_getstring(pScript, &fileName);
char *animEnd;
if (scriptfile_getbraces(pScript, &animEnd))
break;
if (!firstPass)
{
dukeanim_t *animPtr = Anim_Find(fileName);
if (!animPtr)
{
animPtr = Anim_Create(fileName);
animPtr->framedelay = 10;
animPtr->frameflags = 0;
}
int32_t temp;
while (pScript->textptr < animEnd)
{
switch (getatoken(pScript, animTokens, ARRAY_SIZE(animTokens)))
{
case T_DELAY:
scriptfile_getnumber(pScript, &temp);
animPtr->framedelay = temp;
break;
case T_ASPECT:
{
double dtemp, dtemp2;
scriptfile_getdouble(pScript, &dtemp);
scriptfile_getdouble(pScript, &dtemp2);
animPtr->frameaspect1 = dtemp;
animPtr->frameaspect2 = dtemp2;
break;
}
case T_SOUND:
{
char *animSoundsEnd = NULL;
if (scriptfile_getbraces(pScript, &animSoundsEnd))
break;
parsedefinitions_game_animsounds(pScript, animSoundsEnd, fileName, animPtr);
break;
}
case T_FORCEFILTER:
animPtr->frameflags |= CUTSCENE_FORCEFILTER;
break;
case T_FORCENOFILTER:
animPtr->frameflags |= CUTSCENE_FORCENOFILTER;
break;
case T_TEXTUREFILTER:
animPtr->frameflags |= CUTSCENE_TEXTUREFILTER;
break;
}
}
}
else
pScript->textptr = animEnd;
}
break;
case T_ANIMSOUNDS:
{
char *tokenPtr = pScript->ltextptr;
char *fileName = NULL;
scriptfile_getstring(pScript, &fileName);
if (!fileName)
break;
char *animSoundsEnd = NULL;
if (scriptfile_getbraces(pScript, &animSoundsEnd))
break;
if (firstPass)
{
pScript->textptr = animSoundsEnd;
break;
}
dukeanim_t *animPtr = Anim_Find(fileName);
if (!animPtr)
{
Printf("Error: expected animation filename on line %s:%d\n",
pScript->filename, scriptfile_getlinum(pScript, tokenPtr));
break;
}
parsedefinitions_game_animsounds(pScript, animSoundsEnd, fileName, animPtr);
}
break;
case T_SOUND:
{
char *tokenPtr = pScript->ltextptr;
char *fileName = NULL;
char *musicEnd;
double volume = 1.0;
int32_t soundNum = -1;
int32_t maxpitch = 0;
int32_t minpitch = 0;
int32_t priority = 0;
int32_t type = 0;
int32_t distance = 0;
if (scriptfile_getbraces(pScript, &musicEnd))
break;
while (pScript->textptr < musicEnd)
{
switch (getatoken(pScript, soundTokens, ARRAY_SIZE(soundTokens)))
{
case T_ID: scriptfile_getsymbol(pScript, &soundNum); break;
case T_FILE: scriptfile_getstring(pScript, &fileName); break;
case T_MINPITCH: scriptfile_getsymbol(pScript, &minpitch); break;
case T_MAXPITCH: scriptfile_getsymbol(pScript, &maxpitch); break;
case T_PRIORITY: scriptfile_getsymbol(pScript, &priority); break;
case T_TYPE: scriptfile_getsymbol(pScript, &type); break;
case T_DISTANCE: scriptfile_getsymbol(pScript, &distance); break;
case T_VOLUME: scriptfile_getdouble(pScript, &volume); break;
}
}
if (!firstPass)
{
if (soundNum==-1)
{
Printf("Error: missing ID for sound definition near line %s:%d\n", pScript->filename, scriptfile_getlinum(pScript,tokenPtr));
break;
}
if (fileName == NULL || fileSystem.FileExists(fileName))
break;
// maybe I should have just packed this into a sound_t and passed a reference...
if (S_DefineSound(soundNum, fileName, minpitch, maxpitch, priority, type, distance, volume) == -1)
Printf("Error: invalid sound ID on line %s:%d\n", pScript->filename, scriptfile_getlinum(pScript,tokenPtr));
}
}
break;
#endif
case T_GLOBALGAMEFLAGS: scriptfile_getnumber(pScript, &blood_globalflags); break;
case T_EOF: return 0;
default: break;
@ -1688,11 +1494,11 @@ int loaddefinitions_game(const char *fileName, int32_t firstPass)
}
bool DemoRecordStatus(void) {
return gDemo.at0;
return false;
}
bool VanillaMode() {
return gDemo.m_bLegacy && gDemo.at1;
return false;
}
int sndTryPlaySpecialMusic(int nMusic)

View file

@ -32,7 +32,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "levels.h"
#include "qav.h"
#include "view.h"
#include "demo.h"
#include "network.h"
#include "mmulti.h"
#include "c_bind.h"
@ -258,8 +257,6 @@ void GameInterface::StartGame(FNewGameStartup& gs)
gGameOptions.nEpisode = gs.Episode;
gSkill = gs.Skill;
gGameOptions.nLevel = gs.Level;
if (gDemo.at1)
gDemo.StopPlayback();
gStartNewGame = true;
gCheatMgr.sub_5BCF4();
}

View file

@ -49,9 +49,6 @@ SPRITEHIT gSpriteHit[kMaxXSprites];
int xvel[kMaxSprites], yvel[kMaxSprites], zvel[kMaxSprites];
#ifdef POLYMER
PolymerLight_t gPolymerLight[kMaxSprites];
#endif
char qsprite_filler[kMaxSprites], qsector_filler[kMaxSectors];
@ -66,27 +63,6 @@ void dbCrypt(char *pPtr, int nLength, int nKey)
}
}
#ifdef POLYMER
void DeleteLight(int32_t s)
{
if (gPolymerLight[s].lightId >= 0)
polymer_deletelight(gPolymerLight[s].lightId);
gPolymerLight[s].lightId = -1;
gPolymerLight[s].lightptr = NULL;
}
void G_Polymer_UnInit(void)
{
int32_t i;
for (i = 0; i < kMaxSprites; i++)
DeleteLight(i);
}
#endif
void InsertSpriteSect(int nSprite, int nSector)
{
dassert(nSprite >= 0 && nSprite < kMaxSprites);
@ -217,10 +193,6 @@ int InsertSprite(int nSector, int nStat)
pSprite->index = nSprite;
xvel[nSprite] = yvel[nSprite] = zvel[nSprite] = 0;
#ifdef POLYMER
gPolymerLight[nSprite].lightId = -1;
#endif
Numsprites++;
return nSprite;
@ -233,10 +205,6 @@ int qinsertsprite(short nSector, short nStat) // Replace
int DeleteSprite(int nSprite)
{
#ifdef POLYMER
if (gPolymerLight[nSprite].lightptr != NULL && videoGetRenderMode() == REND_POLYMER)
DeleteLight(nSprite);
#endif
if (sprite[nSprite].extra > 0)
{
dbDeleteXSprite(sprite[nSprite].extra);
@ -600,7 +568,7 @@ unsigned int dbReadMapCRC(const char *pPath)
fr.Read(&header, 6);
if (memcmp(header.signature, "BLM\x1a", 4))
{
I_Error("%d: Map file corrupted.");
I_Error("%s: Map file corrupted.", mapname.GetChars());
}
int ver = LittleShort(header.version);
if ((ver & 0xff00) == 0x600)
@ -612,7 +580,7 @@ unsigned int dbReadMapCRC(const char *pPath)
}
else
{
I_Error("%s: Map file is wrong version.");
I_Error("%s: Map file is wrong version.", mapname.GetChars());
}
fr.Seek(-4, FileReader::SeekEnd);
return fr.ReadInt32();
@ -643,14 +611,14 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short
if (!fr.isOpen())
{
Printf("Error opening map file %s", pPath);
Printf("Error opening map file %s", mapname.GetChars());
return -1;
}
MAPSIGNATURE header;
fr.Read(&header, 6);
if (memcmp(header.signature, "BLM\x1a", 4))
{
Printf("Map file corrupted");
Printf("%s: Map file corrupted", mapname.GetChars());
return -1;
}
byte_1A76C8 = 0;
@ -665,7 +633,7 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short
#endif
} else {
Printf("Map file is wrong version");
Printf("%s: Map file is wrong version", mapname.GetChars());
return -1;
}
@ -710,13 +678,13 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short
}
else
{
Printf("Corrupted Map file");
Printf("%s: Corrupted Map file", mapname.GetChars());
return -1;
}
}
else if (mapHeader.at16)
{
Printf("Corrupted Map file");
Printf("%s: Corrupted Map file", mapname.GetChars());
return -1;
}
parallaxtype = mapHeader.at1a;
@ -1093,7 +1061,7 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short
md4once(buffer.Data(), buffer.Size(), g_loadedMapHack.md4);
if (CalcCRC32(buffer.Data(), buffer.Size() -4) != nCRC)
{
Printf("Map File does not match CRC");
Printf("%s: Map File does not match CRC", mapname.GetChars());
return -1;
}
if (pCRC)
@ -1111,21 +1079,16 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short
}
else
{
Printf("Corrupted Map file");
Printf("%s: Corrupted Map file", mapname.GetChars());
return -1;
}
}
else if (gSongId != 0)
{
Printf("Corrupted Map file");
Printf("%s: Corrupted Map file", mapname.GetChars());
return -1;
}
#ifdef POLYMER
if (videoGetRenderMode() == REND_POLYMER)
polymer_loadboard();
#endif
if ((header.version & 0xff00) == 0x600)
{
switch (header.version&0xff)

View file

@ -1,608 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2010-2019 EDuke32 developers and contributors
Copyright (C) 2019 Nuke.YKT
This file is part of NBlood.
NBlood is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "ns.h" // Must come before everything else!
#include <stdio.h>
#include <string.h>
#include "common.h"
#include "common_game.h"
#include "mmulti.h"
#include "blood.h"
#include "controls.h"
#include "demo.h"
#include "globals.h"
#include "levels.h"
#include "messages.h"
#include "misc.h"
#include "network.h"
#include "player.h"
#include "screen.h"
#include "view.h"
#include "gamecontrol.h"
#include "menu.h"
#include "gameconfigfile.h"
#include "findfile.h"
BEGIN_BLD_NS
int nBuild = 0;
void ReadGameOptionsLegacy(GAMEOPTIONS &gameOptions, GAMEOPTIONSLEGACY &gameOptionsLegacy)
{
gameOptions.nGameType = gameOptionsLegacy.nGameType;
gameOptions.nDifficulty = gameOptionsLegacy.nDifficulty;
gameOptions.nEpisode = gameOptionsLegacy.nEpisode;
gameOptions.nLevel = gameOptionsLegacy.nLevel;
strcpy(gameOptions.zLevelName, gameOptionsLegacy.zLevelName);
gameOptions.nTrackNumber = gameOptionsLegacy.nTrackNumber;
gameOptions.nSaveGameSlot = gameOptionsLegacy.nSaveGameSlot;
gameOptions.picEntry = gameOptionsLegacy.picEntry;
gameOptions.uMapCRC = gameOptionsLegacy.uMapCRC;
gameOptions.nMonsterSettings = gameOptionsLegacy.nMonsterSettings;
gameOptions.uGameFlags = gameOptionsLegacy.uGameFlags;
gameOptions.uNetGameFlags = gameOptionsLegacy.uNetGameFlags;
gameOptions.nWeaponSettings = gameOptionsLegacy.nWeaponSettings;
gameOptions.nItemSettings = gameOptionsLegacy.nItemSettings;
gameOptions.nRespawnSettings = gameOptionsLegacy.nRespawnSettings;
gameOptions.nTeamSettings = gameOptionsLegacy.nTeamSettings;
gameOptions.nMonsterRespawnTime = gameOptionsLegacy.nMonsterRespawnTime;
gameOptions.nWeaponRespawnTime = gameOptionsLegacy.nWeaponRespawnTime;
gameOptions.nItemRespawnTime = gameOptionsLegacy.nItemRespawnTime;
gameOptions.nSpecialRespawnTime = gameOptionsLegacy.nSpecialRespawnTime;
}
CDemo gDemo;
CDemo::CDemo()
{
nBuild = 4;
at0 = 0;
at1 = 0;
at3 = 0;
hRFile = NULL;
atb = 0;
pFirstDemo = NULL;
pCurrentDemo = NULL;
at59ef = 0;
at2 = 0;
memset(&atf, 0, sizeof(atf));
m_bLegacy = false;
}
CDemo::~CDemo()
{
at0 = 0;
at1 = 0;
at3 = 0;
atb = 0;
memset(&atf, 0, sizeof(atf));
if (hRFile != NULL)
{
fclose(hRFile);
hRFile = NULL;
}
auto pNextDemo = pFirstDemo;
for (auto pDemo = pFirstDemo; pDemo != NULL; pDemo = pNextDemo)
{
pNextDemo = pDemo->pNext;
delete pDemo;
}
pFirstDemo = NULL;
pCurrentDemo = NULL;
at59ef = 0;
m_bLegacy = false;
}
bool CDemo::Create(const char *pzFile)
{
char buffer[BMAX_PATH];
char vc = 0;
if (at0 || at1)
ThrowError("CDemo::Create called during demo record/playback process.");
if (!pzFile)
{
for (int i = 0; i < 8 && !vc; i++)
{
snprintf(buffer, BMAX_PATH, "%s%s0%02d.dem", G_GetDemoPath().GetChars(), BloodIniPre, i);
if (access(buffer, 0) != -1)
vc = 1;
}
if (vc == 1)
{
hRFile = fopen(buffer, "wb");
if (hRFile == NULL)
return false;
}
}
else
{
snprintf(buffer, BMAX_PATH, "%s%s", G_GetDemoPath().GetChars(), pzFile);
hRFile = fopen(buffer, "wb");
if (hRFile == NULL)
return false;
}
at0 = 1;
atb = 0;
return true;
}
void CDemo::Write(GINPUT *pPlayerInputs)
{
dassert(pPlayerInputs != NULL);
if (!at0)
return;
if (atb == 0)
{
atf.signature = 0x1a4d4445; // '\x1aMDE';
atf.nVersion = BYTEVERSION;
atf.nBuild = nBuild;
atf.nInputCount = 0;
atf.nNetPlayers = gNetPlayers;
atf.nMyConnectIndex = myconnectindex;
atf.nConnectHead = connecthead;
memcpy(atf.connectPoints, connectpoint2, sizeof(atf.connectPoints));
memcpy(&m_gameOptions, &gGameOptions, sizeof(gGameOptions));
fwrite(&atf, sizeof(DEMOHEADER), 1, hRFile);
fwrite(&m_gameOptions, sizeof(GAMEOPTIONS), 1, hRFile);
}
for (int p = connecthead; p >= 0; p = connectpoint2[p])
{
memcpy(&at1aa[atb&1023], &pPlayerInputs[p], sizeof(GINPUT));
atb++;
if((atb&(kInputBufferSize-1))==0)
FlushInput(kInputBufferSize);
}
}
void CDemo::Close(void)
{
if (at0)
{
if (atb&(kInputBufferSize-1))
FlushInput(atb&(kInputBufferSize-1));
atf.nInputCount = atb;
fseek(hRFile, 0, SEEK_SET);
fwrite(&atf, sizeof(DEMOHEADER), 1, hRFile);
fwrite(&m_gameOptions, sizeof(GAMEOPTIONS), 1, hRFile);
}
if (hPFile.isOpen())
{
hPFile.Close();
}
if (hRFile != NULL)
{
fclose(hRFile);
hRFile = NULL;
}
at0 = 0;
at1 = 0;
}
bool CDemo::SetupPlayback(const char *pzFile)
{
at0 = 0;
at1 = 0;
if (pzFile)
{
if (!hPFile.OpenFile(pzFile))
return false;
}
else
{
if (!pCurrentDemo)
return false;
if (!hPFile.OpenFile(pCurrentDemo->zName))
return false;
}
hPFile.Read(&atf, sizeof(DEMOHEADER));
#if B_BIG_ENDIAN == 1
atf.signature = B_LITTLE32(atf.signature);
atf.nVersion = B_LITTLE16(atf.nVersion);
atf.nBuild = B_LITTLE32(atf.nBuild);
atf.nInputCount = B_LITTLE32(atf.nInputCount);
atf.nNetPlayers = B_LITTLE32(atf.nNetPlayers);
atf.nMyConnectIndex = B_LITTLE16(atf.nMyConnectIndex);
atf.nConnectHead = B_LITTLE16(atf.nConnectHead);
atf.nMyConnectIndex = B_LITTLE16(atf.nMyConnectIndex);
for (int i = 0; i < 8; i++)
atf.connectPoints[i] = B_LITTLE16(atf.connectPoints[i]);
#endif
// if (aimHeight.signature != '\x1aMED' && aimHeight.signature != '\x1aMDE')
if (atf.signature != 0x1a4d4544 && atf.signature != 0x1a4d4445)
return 0;
m_bLegacy = atf.signature == 0x1a4d4544;
if (m_bLegacy)
{
GAMEOPTIONSLEGACY gameOptions;
if (BloodVersion != atf.nVersion)
return 0;
hPFile.Read(&gameOptions, sizeof(GAMEOPTIONSLEGACY));
ReadGameOptionsLegacy(m_gameOptions, gameOptions);
}
else
{
if (BYTEVERSION != atf.nVersion)
return 0;
hPFile.Read(&m_gameOptions, sizeof(GAMEOPTIONS));
}
#if B_BIG_ENDIAN == 1
m_gameOptions.nEpisode = B_LITTLE32(m_gameOptions.nEpisode);
m_gameOptions.nLevel = B_LITTLE32(m_gameOptions.nLevel);
m_gameOptions.nTrackNumber = B_LITTLE32(m_gameOptions.nTrackNumber);
m_gameOptions.nSaveGameSlot = B_LITTLE16(m_gameOptions.nSaveGameSlot);
m_gameOptions.picEntry = B_LITTLE32(m_gameOptions.picEntry);
m_gameOptions.uMapCRC = B_LITTLE32(m_gameOptions.uMapCRC);
m_gameOptions.uGameFlags = B_LITTLE32(m_gameOptions.uGameFlags);
m_gameOptions.uNetGameFlags = B_LITTLE32(m_gameOptions.uNetGameFlags);
m_gameOptions.nMonsterRespawnTime = B_LITTLE32(m_gameOptions.nMonsterRespawnTime);
m_gameOptions.nWeaponRespawnTime = B_LITTLE32(m_gameOptions.nWeaponRespawnTime);
m_gameOptions.nItemRespawnTime = B_LITTLE32(m_gameOptions.nItemRespawnTime);
m_gameOptions.nSpecialRespawnTime = B_LITTLE32(m_gameOptions.nSpecialRespawnTime);
#endif
at0 = 0;
at1 = 1;
M_UnpauseSound();
return 1;
}
void CDemo::ProcessKeys(void)
{
switch (gInputMode)
{
case kInputMessage:
gPlayerMsg.ProcessKeys();
break;
case kInputGame:
{
char nKey;
while ((nKey = inputState.keyGetScan()) != 0)
{
switch (nKey)
{
case sc_F12:
gViewIndex = connectpoint2[gViewIndex];
if (gViewIndex == -1)
gViewIndex = connecthead;
gView = &gPlayer[gViewIndex];
break;
default:
if (!M_Active())
{
M_StartControlPanel(true);
M_SetMenu(NAME_Mainmenu);
}
}
}
break;
default:
gInputMode = kInputGame;
break;
}
}
}
void CDemo::Playback(void)
{
inputState.SetBindsEnabled(false);
ready2send = 0;
int v4 = 0;
gNetFifoClock = totalclock;
gViewMode = 3;
_DEMOPLAYBACK:
while (at1 && !gQuitGame)
{
while (totalclock >= gNetFifoClock && !gQuitGame)
{
if (!v4)
{
viewResizeView(gViewSize);
viewSetMessage("");
gNetPlayers = atf.nNetPlayers;
atb = atf.nInputCount;
myconnectindex = atf.nMyConnectIndex;
connecthead = atf.nConnectHead;
for (int i = 0; i < 8; i++)
connectpoint2[i] = atf.connectPoints[i];
memset(gNetFifoHead, 0, sizeof(gNetFifoHead));
gNetFifoTail = 0;
//memcpy(connectpoint2, aimHeight.connectPoints, sizeof(aimHeight.connectPoints));
memcpy(&gGameOptions, &m_gameOptions, sizeof(GAMEOPTIONS));
gSkill = gGameOptions.nDifficulty;
for (int i = 0; i < 8; i++)
playerInit(i, 0);
StartLevel(&gGameOptions);
for (int i = 0; i < 8; i++)
{
gProfile[i].nAutoAim = 1;
gProfile[i].nWeaponSwitch = 1;
}
}
ready2send = 0;
C_RunDelayedCommands();
if (!gDemo.at1)
break;
ProcessKeys();
for (int p = connecthead; p >= 0; p = connectpoint2[p])
{
if ((v4&1023) == 0)
{
unsigned int nSize = atb-v4;
if (nSize > kInputBufferSize)
nSize = kInputBufferSize;
ReadInput(nSize);
}
memcpy(&gFifoInput[gNetFifoHead[p]&255], &at1aa[v4&1023], sizeof(GINPUT));
gNetFifoHead[p]++;
v4++;
if (v4 >= atf.nInputCount)
{
ready2send = 0;
if (at59ef != 1)
{
v4 = 0;
Close();
NextDemo();
gNetFifoClock = totalclock;
goto _DEMOPLAYBACK;
}
else
{
int const nOffset = sizeof(DEMOHEADER)+(m_bLegacy ? sizeof(GAMEOPTIONSLEGACY) : sizeof(GAMEOPTIONS));
hPFile.Seek(nOffset, FileReader::SeekSet);
v4 = 0;
}
}
}
gNetFifoClock += 4;
if (!gQuitGame)
ProcessFrame();
ready2send = 0;
}
if (G_FPSLimit())
{
handleevents();
D_ProcessEvents();
viewDrawScreen();
videoNextPage();
}
if (TestBitString(gotpic, 2342))
{
FireProcess();
ClearBitString(gotpic, 2342);
}
}
Close();
}
void CDemo::StopPlayback(void)
{
at1 = 0;
}
void CDemo::LoadDemoInfo(void)
{
auto pDemo = &pFirstDemo;
at59ef = 0;
char zFN[BMAX_PATH];
snprintf(zFN, BMAX_PATH, "%s%s*.dem", G_GetDemoPath().GetChars(), BloodIniPre);
TArray<FString> demos;
D_AddWildFile(demos, zFN, ".dem", GameConfig);
FStringf ini("%s.ini", BloodIniPre);
int lump = fileSystem.FindFile(ini);
if (lump >= 0)
{
auto path = fileSystem.GetResourceFileFullName(fileSystem.GetFileContainer(lump));
ini.Format("%s*.dem", path);
D_AddWildFile(demos, ini, ".dem", GameConfig);
}
for (auto &filename : demos)
{
FileReader hFile;
if (!hFile.OpenFile(filename))
ThrowError("Error loading demo file header.");
hFile.Read(&atf, sizeof(atf));
#if B_BIG_ENDIAN == 1
atf.signature = B_LITTLE32(atf.signature);
atf.nVersion = B_LITTLE16(atf.nVersion);
#endif
if ((atf.signature == 0x1a4d4544 /* '\x1aMED' */&& atf.nVersion == BloodVersion)
|| (atf.signature == 0x1a4d4445 /* '\x1aMDE' */ && atf.nVersion == BYTEVERSION))
{
*pDemo = new DEMOCHAIN;
(*pDemo)->pNext = NULL;
Bstrncpy((*pDemo)->zName, filename, BMAX_PATH);
at59ef++;
pDemo = &(*pDemo)->pNext;
}
}
pCurrentDemo = pFirstDemo;
}
void CDemo::NextDemo(void)
{
pCurrentDemo = pCurrentDemo->pNext ? pCurrentDemo->pNext : pFirstDemo;
SetupPlayback(NULL);
}
const int nInputSize = 17;
const int nInputSizeLegacy = 22;
void CDemo::FlushInput(int nCount)
{
char pBuffer[nInputSize*kInputBufferSize];
BitWriter bitWriter(pBuffer, sizeof(pBuffer));
for (int i = 0; i < nCount; i++)
{
GINPUT *pInput = &at1aa[i];
bitWriter.writeBit(pInput->syncFlags.buttonChange);
bitWriter.writeBit(pInput->syncFlags.keyChange);
bitWriter.writeBit(pInput->syncFlags.useChange);
bitWriter.writeBit(pInput->syncFlags.weaponChange);
bitWriter.writeBit(pInput->syncFlags.mlookChange);
bitWriter.writeBit(pInput->syncFlags.run);
bitWriter.write(pInput->forward, 16);
bitWriter.write(pInput->q16turn, 32);
bitWriter.write(pInput->strafe, 16);
bitWriter.writeBit(pInput->buttonFlags.jump);
bitWriter.writeBit(pInput->buttonFlags.crouch);
bitWriter.writeBit(pInput->buttonFlags.shoot);
bitWriter.writeBit(pInput->buttonFlags.shoot2);
bitWriter.writeBit(pInput->buttonFlags.lookUp);
bitWriter.writeBit(pInput->buttonFlags.lookDown);
bitWriter.writeBit(pInput->keyFlags.action);
bitWriter.writeBit(pInput->keyFlags.jab);
bitWriter.writeBit(pInput->keyFlags.prevItem);
bitWriter.writeBit(pInput->keyFlags.nextItem);
bitWriter.writeBit(pInput->keyFlags.useItem);
bitWriter.writeBit(pInput->keyFlags.prevWeapon);
bitWriter.writeBit(pInput->keyFlags.nextWeapon);
bitWriter.writeBit(pInput->keyFlags.holsterWeapon);
bitWriter.writeBit(pInput->keyFlags.lookCenter);
bitWriter.writeBit(pInput->keyFlags.lookLeft);
bitWriter.writeBit(pInput->keyFlags.lookRight);
bitWriter.writeBit(pInput->keyFlags.spin180);
bitWriter.writeBit(pInput->keyFlags.pause);
bitWriter.writeBit(pInput->keyFlags.quit);
bitWriter.writeBit(pInput->keyFlags.restart);
bitWriter.writeBit(pInput->useFlags.useBeastVision);
bitWriter.writeBit(pInput->useFlags.useCrystalBall);
bitWriter.writeBit(pInput->useFlags.useJumpBoots);
bitWriter.writeBit(pInput->useFlags.useMedKit);
bitWriter.write(pInput->newWeapon, 8);
bitWriter.write(pInput->q16mlook, 32);
bitWriter.skipBits(1);
}
fwrite(pBuffer, 1, nInputSize*nCount, hRFile);
}
void CDemo::ReadInput(int nCount)
{
if (m_bLegacy)
{
char pBuffer[nInputSizeLegacy*kInputBufferSize];
hPFile.Read(pBuffer, nInputSizeLegacy*nCount);
BitReader bitReader(pBuffer, sizeof(pBuffer));
memset(at1aa, 0, nCount * sizeof(GINPUT));
for (int i = 0; i < nCount; i++)
{
GINPUT *pInput = &at1aa[i];
pInput->syncFlags.buttonChange = bitReader.readBit();
pInput->syncFlags.keyChange = bitReader.readBit();
pInput->syncFlags.useChange = bitReader.readBit();
pInput->syncFlags.weaponChange = bitReader.readBit();
pInput->syncFlags.mlookChange = bitReader.readBit();
pInput->syncFlags.run = bitReader.readBit();
bitReader.skipBits(26);
pInput->forward = bitReader.readSigned(8) << 8;
pInput->q16turn = fix16_from_int(bitReader.readSigned(16) >> 2);
pInput->strafe = bitReader.readSigned(8) << 8;
pInput->buttonFlags.jump = bitReader.readBit();
pInput->buttonFlags.crouch = bitReader.readBit();
pInput->buttonFlags.shoot = bitReader.readBit();
pInput->buttonFlags.shoot2 = bitReader.readBit();
pInput->buttonFlags.lookUp = bitReader.readBit();
pInput->buttonFlags.lookDown = bitReader.readBit();
bitReader.skipBits(26);
pInput->keyFlags.action = bitReader.readBit();
pInput->keyFlags.jab = bitReader.readBit();
pInput->keyFlags.prevItem = bitReader.readBit();
pInput->keyFlags.nextItem = bitReader.readBit();
pInput->keyFlags.useItem = bitReader.readBit();
pInput->keyFlags.prevWeapon = bitReader.readBit();
pInput->keyFlags.nextWeapon = bitReader.readBit();
pInput->keyFlags.holsterWeapon = bitReader.readBit();
pInput->keyFlags.lookCenter = bitReader.readBit();
pInput->keyFlags.lookLeft = bitReader.readBit();
pInput->keyFlags.lookRight = bitReader.readBit();
pInput->keyFlags.spin180 = bitReader.readBit();
pInput->keyFlags.pause = bitReader.readBit();
pInput->keyFlags.quit = bitReader.readBit();
pInput->keyFlags.restart = bitReader.readBit();
bitReader.skipBits(17);
pInput->useFlags.useBeastVision = bitReader.readBit();
pInput->useFlags.useCrystalBall = bitReader.readBit();
pInput->useFlags.useJumpBoots = bitReader.readBit();
pInput->useFlags.useMedKit = bitReader.readBit();
bitReader.skipBits(28);
pInput->newWeapon = bitReader.readUnsigned(8);
int mlook = bitReader.readSigned(8);
pInput->q16mlook = fix16_from_int(mlook / 4);
}
}
else
{
char pBuffer[nInputSize*kInputBufferSize];
hPFile.Read(pBuffer, nInputSize*nCount);
BitReader bitReader(pBuffer, sizeof(pBuffer));
memset(at1aa, 0, nCount * sizeof(GINPUT));
for (int i = 0; i < nCount; i++)
{
GINPUT *pInput = &at1aa[i];
pInput->syncFlags.buttonChange = bitReader.readBit();
pInput->syncFlags.keyChange = bitReader.readBit();
pInput->syncFlags.useChange = bitReader.readBit();
pInput->syncFlags.weaponChange = bitReader.readBit();
pInput->syncFlags.mlookChange = bitReader.readBit();
pInput->syncFlags.run = bitReader.readBit();
pInput->forward = bitReader.readSigned(16);
pInput->q16turn = bitReader.readSigned(32);
pInput->strafe = bitReader.readSigned(16);
pInput->buttonFlags.jump = bitReader.readBit();
pInput->buttonFlags.crouch = bitReader.readBit();
pInput->buttonFlags.shoot = bitReader.readBit();
pInput->buttonFlags.shoot2 = bitReader.readBit();
pInput->buttonFlags.lookUp = bitReader.readBit();
pInput->buttonFlags.lookDown = bitReader.readBit();
pInput->keyFlags.action = bitReader.readBit();
pInput->keyFlags.jab = bitReader.readBit();
pInput->keyFlags.prevItem = bitReader.readBit();
pInput->keyFlags.nextItem = bitReader.readBit();
pInput->keyFlags.useItem = bitReader.readBit();
pInput->keyFlags.prevWeapon = bitReader.readBit();
pInput->keyFlags.nextWeapon = bitReader.readBit();
pInput->keyFlags.holsterWeapon = bitReader.readBit();
pInput->keyFlags.lookCenter = bitReader.readBit();
pInput->keyFlags.lookLeft = bitReader.readBit();
pInput->keyFlags.lookRight = bitReader.readBit();
pInput->keyFlags.spin180 = bitReader.readBit();
pInput->keyFlags.pause = bitReader.readBit();
pInput->keyFlags.quit = bitReader.readBit();
pInput->keyFlags.restart = bitReader.readBit();
pInput->useFlags.useBeastVision = bitReader.readBit();
pInput->useFlags.useCrystalBall = bitReader.readBit();
pInput->useFlags.useJumpBoots = bitReader.readBit();
pInput->useFlags.useMedKit = bitReader.readBit();
pInput->newWeapon = bitReader.readUnsigned(8);
pInput->q16mlook = bitReader.readSigned(32);
bitReader.skipBits(1);
}
}
}
END_BLD_NS

View file

@ -1,114 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2010-2019 EDuke32 developers and contributors
Copyright (C) 2019 Nuke.YKT
This file is part of NBlood.
NBlood is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#pragma once
#include "controls.h"
#include "levels.h"
BEGIN_BLD_NS
#define kInputBufferSize 1024
#pragma pack(push, 1)
struct GAMEOPTIONSLEGACY {
char nGameType;
char nDifficulty;
int nEpisode;
int nLevel;
char zLevelName[144];
char zLevelSong[144];
int nTrackNumber; //at12a;
char szSaveGameName[16];
char szUserGameName[16];
short nSaveGameSlot;
int picEntry;
unsigned int uMapCRC;
char nMonsterSettings;
int uGameFlags;
int uNetGameFlags;
char nWeaponSettings;
char nItemSettings;
char nRespawnSettings;
char nTeamSettings;
int nMonsterRespawnTime;
int nWeaponRespawnTime;
int nItemRespawnTime;
int nSpecialRespawnTime;
};
struct DEMOHEADER
{
int signature;
short nVersion;
int nBuild;
int nInputCount;
int nNetPlayers;
short nMyConnectIndex;
short nConnectHead;
short connectPoints[8];
};
#pragma pack(pop)
struct DEMOCHAIN
{
DEMOCHAIN *pNext;
char zName[BMAX_PATH];
};
class CDemo {
public:
CDemo();
~CDemo();
bool Create(const char *);
void Write(GINPUT *);
void Close(void);
bool SetupPlayback(const char *);
void ProcessKeys(void);
void Playback(void);
void StopPlayback(void);
void LoadDemoInfo(void);
void NextDemo(void);
void FlushInput(int nCount);
void ReadInput(int nCount);
bool at0; // record
bool at1; // playback
bool m_bLegacy;
char at2;
int at3;
FileReader hPFile;
FILE *hRFile;
int atb;
DEMOHEADER atf;
GAMEOPTIONS m_gameOptions;
GINPUT at1aa[kInputBufferSize];
const char **pzDemoFile;
DEMOCHAIN *pFirstDemo;
DEMOCHAIN *pCurrentDemo;
int at59ef;
};
extern CDemo gDemo;
END_BLD_NS

View file

@ -29,7 +29,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "common_game.h"
#include "ai.h"
#include "blood.h"
#include "demo.h"
#include "globals.h"
#include "db.h"
#include "messages.h"
@ -477,10 +476,6 @@ void LoadSave::Write(void *pData, int nSize)
bool GameInterface::LoadGame(FSaveGameNode* node)
{
bool demoWasPlayed = gDemo.at1;
if (gDemo.at1)
gDemo.Close();
sndKillAllSounds();
sfxKillAllSounds();
ambKillAll();

View file

@ -28,7 +28,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "gamecontrol.h"
#include "common_game.h"
#include "blood.h"
#include "demo.h"
#include "eventq.h"
#include "globals.h"
#include "levels.h"
@ -280,18 +279,6 @@ void LevelWarp(int nEpisode, int nLevel)
viewResizeView(gViewSize);
}
void LevelWarpAndRecord(int nEpisode, int nLevel)
{
char buffer[BMAX_PATH];
levelSetupOptions(nEpisode, nLevel);
gGameStarted = false;
strcpy(buffer, levelGetFilename(nEpisode, nLevel));
ChangeExtension(buffer, ".DEM");
gDemo.Create(buffer);
StartLevel(&gGameOptions);
viewResizeView(gViewSize);
}
CGameMessageMgr::CGameMessageMgr()
{
if (!VanillaMode())
@ -674,7 +661,6 @@ void CCheatMgr::Process(CCheatMgr::CHEATCODE nCheatCode, char* pzArgs)
{
dassert(nCheatCode > kCheatNone && nCheatCode < kCheatMax);
if (gDemo.at0) return;
if (nCheatCode == kCheatRate)
{
r_showfps = !r_showfps;
@ -686,8 +672,7 @@ void CCheatMgr::Process(CCheatMgr::CHEATCODE nCheatCode, char* pzArgs)
switch (nCheatCode)
{
case kCheatSpielberg:
if (parseArgs(pzArgs, &nEpisode, &nLevel) == 2)
LevelWarpAndRecord(nEpisode, nLevel);
// demo record
break;
case kCheat1:
SetAmmo(true);

View file

@ -29,7 +29,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "mmulti.h"
#include "common_game.h"
#include "blood.h"
#include "demo.h"
#include "globals.h"
#include "levels.h"
#include "messages.h"
@ -54,7 +53,7 @@ static int osdcmd_map(CCmdFuncPtr parm)
if (!fileSystem.FindFile(mapfilename))
{
Printf(TEXTCOLOR_RED "map: file \"%s\" not found.\n", mapfilename);
Printf(TEXTCOLOR_RED "map: file \"%s\" not found.\n", mapfilename.GetChars());
return CCMD_OK;
}
@ -70,9 +69,6 @@ static int osdcmd_map(CCmdFuncPtr parm)
}
// Map has not been defined. Treat as user map.
if (gDemo.at1)
gDemo.StopPlayback();
levelAddUserMap(mapname);
if (numplayers > 1)
@ -90,30 +86,6 @@ static int osdcmd_map(CCmdFuncPtr parm)
return CCMD_OK;
}
static int osdcmd_demo(CCmdFuncPtr parm)
{
if (numplayers > 1)
{
Printf("Command not allowed in multiplayer\n");
return CCMD_OK;
}
//if (ps[myconnectindex].gm & MODE_GAME)
//{
// Printf("demo: Must not be in a game.\n");
// return CCMD_OK;
//}
if (parm->numparms != 1/* && parm->numparms != 2*/)
return CCMD_SHOWHELP;
gDemo.SetupPlayback(parm->parms[0]);
gGameStarted = 0;
gDemo.Playback();
return CCMD_OK;
}
static int osdcmd_give(CCmdFuncPtr parm)
{
@ -241,7 +213,6 @@ static int osdcmd_levelwarp(CCmdFuncPtr parm)
int32_t registerosdcommands(void)
{
C_RegisterFunction("map","map <mapname>: loads the given map", osdcmd_map);
C_RegisterFunction("demo","demo <demofile or demonum>: starts the given demo", osdcmd_demo);
C_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);
C_RegisterFunction("god","god: toggles god mode", osdcmd_god);

View file

@ -31,7 +31,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "blood.h"
#include "callback.h"
#include "controls.h"
#include "demo.h"
#include "eventq.h"
#include "fx.h"
#include "gib.h"
@ -1365,8 +1364,6 @@ void ProcessInput(PLAYER *pPlayer)
playerReset(pPlayer);
if (gGameOptions.nGameType == 0 && numplayers == 1)
{
if (gDemo.at0)
gDemo.Close();
pInput->keyFlags.restart = 1;
}
else