- removed Exhumed's demo loop.

It was broken already anyway and also looks like a first grade refactoring blocker.
This commit is contained in:
Christoph Oelckers 2020-08-22 09:31:17 +02:00
parent e1fd0d8d80
commit b96f12aa34
2 changed files with 34 additions and 244 deletions

View file

@ -1180,44 +1180,6 @@ void FinishLevel()
}
}
EDUKE32_STATIC_ASSERT(sizeof(demo_header) == 75);
EDUKE32_STATIC_ASSERT(sizeof(demo_input) == 36);
void WritePlaybackInputs()
{
fwrite(&moveframes, sizeof(moveframes), 1, vcrfp);
fwrite(&sPlayerInput[nLocalPlayer], sizeof(PlayerInput), 1, vcrfp);
}
uint8_t ReadPlaybackInputs()
{
demo_input input;
if (fread(&input, 1, sizeof(input), vcrfp))
{
moveframes = input.moveframes;
sPlayerInput[nLocalPlayer].xVel = input.xVel;
sPlayerInput[nLocalPlayer].yVel = input.yVel;
sPlayerInput[nLocalPlayer].nAngle = fix16_from_int(input.nAngle<<2);
sPlayerInput[nLocalPlayer].buttons = input.buttons;
sPlayerInput[nLocalPlayer].nTarget = input.nTarget;
sPlayerInput[nLocalPlayer].horizon = fix16_from_int(input.horizon);
sPlayerInput[nLocalPlayer].nItem = input.nItem;
sPlayerInput[nLocalPlayer].h = input.h;
sPlayerInput[nLocalPlayer].i = input.i;
besttarget = sPlayerInput[nLocalPlayer].nTarget;
Ra[nLocalPlayer].nTarget = besttarget;
return true;
}
else
{
fclose(vcrfp);
vcrfp = NULL;
bPlayback = false;
return false;
}
}
void SetHiRes()
{
@ -1468,10 +1430,6 @@ void PatchDemoStrings()
void ExitGame()
{
if (bRecord) {
fclose(vcrfp);
}
ShutDown();
throw CExitEvent(0);
}
@ -1493,33 +1451,6 @@ void CheckCommandLine(int argc, char const* const* argv, int &doTitle)
if (Bstrcasecmp(pChar, "nocreatures") == 0) {
bNoCreatures = true;
}
else if (Bstrcasecmp(pChar, "record") == 0)
{
if (!bPlayback)
{
vcrfp = fopen("data.vcr", "wb+");
if (vcrfp != NULL) {
bRecord = true;
}
else {
DebugOut("Can't open data file for recording\n");
}
}
}
else if (Bstrcasecmp(pChar, "playback") == 0)
{
if (!bRecord)
{
vcrfp = fopen("data.vcr", "rb");
if (vcrfp != NULL) {
bPlayback = true;
doTitle = false;
}
else {
DebugOut("Can't open data file 'data.vcr' for reading\n");
}
}
}
else if (Bstrcasecmp(pChar, "network") == 0)
{
nNetPlayerCount = -1;
@ -1768,11 +1699,6 @@ int GameInterface::app_main()
levelnew = forcelevel;
goto STARTGAME1;
}
// no forcelevel specified...
if (bPlayback)
{
goto STARTGAME1;
}
MENU:
SavePosition = -1;
nMenu = menu_Menu(0);
@ -1788,18 +1714,8 @@ MENU:
case 6:
goto GAMELOOP;
case 9:
vcrfp = fopen("demo.vcr", "rb");
if (vcrfp == NULL) {
goto MENU;
}
InitRandom();
bInDemo = true;
bPlayback = true;
inputState.ClearAllInput();
break;
}
STARTGAME1:
levelnew = 1;
levelnum = 1;
@ -1832,14 +1748,6 @@ STARTGAME2:
nNetMoves = 0;
if (bPlayback)
{
menu_GameLoad2(vcrfp, true);
levelnew = GameStats.nMap;
levelnum = GameStats.nMap;
forcelevel = GameStats.nMap;
}
if (forcelevel > -1)
{
// YELLOW SECTION
@ -1847,9 +1755,6 @@ STARTGAME2:
UpdateInputs();
forcelevel = -1;
if (bRecord && !bInDemo) {
menu_GameSave2(vcrfp);
}
goto LOOP3;
}
@ -1865,10 +1770,6 @@ STARTGAME2:
lastlevel = -1;
}
if (bRecord && !bInDemo) {
menu_GameSave2(vcrfp);
}
nBestLevel = levelnew - 1;
LOOP1:
@ -1975,116 +1876,6 @@ GAMELOOP:
updatePauseStatus();
CheckKeys();
if (bRecord || bPlayback)
{
bInMove = true;
moveframes = ((int)totalclock - (int)tclocks2) / 4;
if (moveframes > 4)
moveframes = 4;
if (moveframes != 0)
tclocks2 = totalclock;
if (bPlayback)
{
// YELLOW
if (((bInDemo && inputState.keyBufferWaiting()) || !ReadPlaybackInputs()) && inputState.keyGetChar())
{
inputState.ClearAllInput();
bPlayback = false;
bInDemo = false;
if (vcrfp) {
fclose(vcrfp);
}
goto MENU;
}
}
else if (bRecord || moveframes)
{
GetLocalInput();
sPlayerInput[nLocalPlayer].xVel = lPlayerXVel;
sPlayerInput[nLocalPlayer].yVel = lPlayerYVel;
sPlayerInput[nLocalPlayer].buttons = lLocalButtons | lLocalCodes;
sPlayerInput[nLocalPlayer].nAngle = nPlayerDAng;
sPlayerInput[nLocalPlayer].nTarget = besttarget;
Ra[nLocalPlayer].nTarget = besttarget;
lLocalCodes = 0;
nPlayerDAng = 0;
sPlayerInput[nLocalPlayer].horizon = PlayerList[nLocalPlayer].q16horiz;
}
// loc_11F72:
if (bRecord && !bInDemo) {
WritePlaybackInputs();
}
if (nNetPlayerCount)
{
if (moveframes)
{
UpdateInputs();
moveframes = nNetMoveFrames;
}
}
else
{
// loc_11FBC:
while (paused)
{
updatePauseStatus();
}
}
// loc_11FEE:
tclocks += moveframes * 4;
while (moveframes && levelnew < 0)
{
GameMove();
// if (nNetTime > 0)
// {
// nNetTime--;
//
// if (!nNetTime) {
// nFreeze = 3;
// }
// }
// else if (nNetTime == 0)
// {
// if (buttonMap.ButtonDown(gamefunc_Open))
// {
// buttonMap.ClearButton(gamefunc_Open);
// goto MENU2;
// }
// }
}
bInMove = false;
// END YELLOW SECTION
// loc_12149:
if (bInDemo || bPlayback)
{
while (tclocks > totalclock) { HandleAsync(); }
tclocks = totalclock;
}
if (G_FPSLimit())
{
GameDisplay();
}
}
else
{
bInMove = true;
if (paused)
@ -2127,10 +1918,8 @@ GAMELOOP:
while (levelnew < 0 && totalclock >= tclocks + 4)
{
// timerUpdate();
tclocks += 4;
GameMove();
// timerUpdate();
}
}
}
@ -2142,7 +1931,7 @@ GAMELOOP:
{
GameDisplay();
}
}
if (!bInDemo)
{
nMenu = MenuExitCondition;

View file

@ -2698,7 +2698,8 @@ do_default_b:
case 54: // Golden Sarcophagus (End Level)
{
if (!bInDemo) {
if (!bInDemo)
{
FinishLevel();
}
else {