- 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() void SetHiRes()
{ {
@ -1468,10 +1430,6 @@ void PatchDemoStrings()
void ExitGame() void ExitGame()
{ {
if (bRecord) {
fclose(vcrfp);
}
ShutDown(); ShutDown();
throw CExitEvent(0); throw CExitEvent(0);
} }
@ -1493,33 +1451,6 @@ void CheckCommandLine(int argc, char const* const* argv, int &doTitle)
if (Bstrcasecmp(pChar, "nocreatures") == 0) { if (Bstrcasecmp(pChar, "nocreatures") == 0) {
bNoCreatures = true; 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) else if (Bstrcasecmp(pChar, "network") == 0)
{ {
nNetPlayerCount = -1; nNetPlayerCount = -1;
@ -1768,11 +1699,6 @@ int GameInterface::app_main()
levelnew = forcelevel; levelnew = forcelevel;
goto STARTGAME1; goto STARTGAME1;
} }
// no forcelevel specified...
if (bPlayback)
{
goto STARTGAME1;
}
MENU: MENU:
SavePosition = -1; SavePosition = -1;
nMenu = menu_Menu(0); nMenu = menu_Menu(0);
@ -1788,17 +1714,7 @@ MENU:
case 6: case 6:
goto GAMELOOP; goto GAMELOOP;
case 9: case 9:
vcrfp = fopen("demo.vcr", "rb"); goto MENU;
if (vcrfp == NULL) {
goto MENU;
}
InitRandom();
bInDemo = true;
bPlayback = true;
inputState.ClearAllInput();
break;
} }
STARTGAME1: STARTGAME1:
levelnew = 1; levelnew = 1;
@ -1832,14 +1748,6 @@ STARTGAME2:
nNetMoves = 0; nNetMoves = 0;
if (bPlayback)
{
menu_GameLoad2(vcrfp, true);
levelnew = GameStats.nMap;
levelnum = GameStats.nMap;
forcelevel = GameStats.nMap;
}
if (forcelevel > -1) if (forcelevel > -1)
{ {
// YELLOW SECTION // YELLOW SECTION
@ -1847,9 +1755,6 @@ STARTGAME2:
UpdateInputs(); UpdateInputs();
forcelevel = -1; forcelevel = -1;
if (bRecord && !bInDemo) {
menu_GameSave2(vcrfp);
}
goto LOOP3; goto LOOP3;
} }
@ -1865,10 +1770,6 @@ STARTGAME2:
lastlevel = -1; lastlevel = -1;
} }
if (bRecord && !bInDemo) {
menu_GameSave2(vcrfp);
}
nBestLevel = levelnew - 1; nBestLevel = levelnew - 1;
LOOP1: LOOP1:
@ -1975,38 +1876,32 @@ GAMELOOP:
updatePauseStatus(); updatePauseStatus();
CheckKeys(); CheckKeys();
if (bRecord || bPlayback) bInMove = true;
if (paused)
{ {
bInMove = true; tclocks = totalclock - 4;
buttonMap.ResetButtonStates();
moveframes = ((int)totalclock - (int)tclocks2) / 4; }
else
if (moveframes > 4) {
moveframes = 4; while ((totalclock - ototalclock) >= 1 || !bInMove)
if (moveframes != 0)
tclocks2 = totalclock;
if (bPlayback)
{ {
// YELLOW ototalclock = ototalclock + 1;
if (((bInDemo && inputState.keyBufferWaiting()) || !ReadPlaybackInputs()) && inputState.keyGetChar())
{
inputState.ClearAllInput();
bPlayback = false; if (!((int)ototalclock&3) && moveframes < 4)
bInDemo = false; moveframes++;
if (vcrfp) {
fclose(vcrfp);
}
goto MENU;
}
}
else if (bRecord || moveframes)
{
GetLocalInput(); GetLocalInput();
PlayerInterruptKeys();
nPlayerDAng = fix16_sadd(nPlayerDAng, localInput.nAngle);
inita &= kAngleMask;
lPlayerXVel += localInput.yVel * Cos(inita) + localInput.xVel * Sin(inita);
lPlayerYVel += localInput.yVel * Sin(inita) - localInput.xVel * Cos(inita);
lPlayerXVel -= (lPlayerXVel >> 5) + (lPlayerXVel >> 6);
lPlayerYVel -= (lPlayerYVel >> 5) + (lPlayerYVel >> 6);
sPlayerInput[nLocalPlayer].xVel = lPlayerXVel; sPlayerInput[nLocalPlayer].xVel = lPlayerXVel;
sPlayerInput[nLocalPlayer].yVel = lPlayerYVel; sPlayerInput[nLocalPlayer].yVel = lPlayerYVel;
@ -2020,129 +1915,23 @@ GAMELOOP:
nPlayerDAng = 0; nPlayerDAng = 0;
sPlayerInput[nLocalPlayer].horizon = PlayerList[nLocalPlayer].q16horiz; sPlayerInput[nLocalPlayer].horizon = PlayerList[nLocalPlayer].q16horiz;
}
// loc_11F72: while (levelnew < 0 && totalclock >= tclocks + 4)
if (bRecord && !bInDemo) {
WritePlaybackInputs();
}
if (nNetPlayerCount)
{
if (moveframes)
{ {
UpdateInputs(); tclocks += 4;
moveframes = nNetMoveFrames; GameMove();
} }
} }
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 = false;
PlayerInterruptKeys();
if (G_FPSLimit())
{ {
bInMove = true; GameDisplay();
if (paused)
{
tclocks = totalclock - 4;
buttonMap.ResetButtonStates();
}
else
{
while ((totalclock - ototalclock) >= 1 || !bInMove)
{
ototalclock = ototalclock + 1;
if (!((int)ototalclock&3) && moveframes < 4)
moveframes++;
GetLocalInput();
PlayerInterruptKeys();
nPlayerDAng = fix16_sadd(nPlayerDAng, localInput.nAngle);
inita &= kAngleMask;
lPlayerXVel += localInput.yVel * Cos(inita) + localInput.xVel * Sin(inita);
lPlayerYVel += localInput.yVel * Sin(inita) - localInput.xVel * Cos(inita);
lPlayerXVel -= (lPlayerXVel >> 5) + (lPlayerXVel >> 6);
lPlayerYVel -= (lPlayerYVel >> 5) + (lPlayerYVel >> 6);
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;
while (levelnew < 0 && totalclock >= tclocks + 4)
{
// timerUpdate();
tclocks += 4;
GameMove();
// timerUpdate();
}
}
}
bInMove = false;
PlayerInterruptKeys();
if (G_FPSLimit())
{
GameDisplay();
}
} }
if (!bInDemo) if (!bInDemo)
{ {
nMenu = MenuExitCondition; nMenu = MenuExitCondition;

View file

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