- cleaned out demo code.

This commit is contained in:
Christoph Oelckers 2020-07-04 00:12:24 +02:00
parent d13b2dc130
commit f5d363d914
8 changed files with 45 additions and 142 deletions

View file

@ -1,49 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2010 EDuke32 developers and contributors
This file is part of EDuke32.
EDuke32 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.
*/
//-------------------------------------------------------------------------
#ifndef demo_h_
#define demo_h_
#include "compat.h"
#include "files.h"
BEGIN_DUKE_NS
#define DEMOFN_FMT "edemo%03d.edm"
#define LDEMOFN_FMT "demo%d.dmo"
#define MAXDEMOS 1000
extern FileWriter * g_demo_filePtr;
extern char g_firstDemoFile[BMAX_PATH];
extern int32_t g_demo_cnt;
extern int32_t g_demo_goalCnt;
extern int32_t g_demo_paused;
extern FileReader g_demo_recFilePtr;
extern int32_t g_demo_rewind;
extern int32_t g_demo_showStats;
extern int32_t g_demo_totalCnt;
END_DUKE_NS
#endif

View file

@ -29,7 +29,6 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
#include "ns.h" // Must come before everything else!
#include "duke3d.h"
#include "demo.h"
#include "screens.h"
#include "baselayer.h"
#include "m_argv.h"

View file

@ -22,7 +22,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "ns.h" // Must come before everything else!
#include "demo.h"
#include "duke3d.h"
#include "savegame.h"
@ -30,29 +29,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_DUKE_NS
char g_firstDemoFile[BMAX_PATH];
FileWriter *g_demo_filePtr{}; // write
FileReader g_demo_recFilePtr; // read
int32_t g_demo_cnt;
int32_t g_demo_goalCnt=0;
int32_t g_demo_totalCnt;
int32_t g_demo_paused=0;
int32_t g_demo_rewind=0;
int32_t g_demo_showStats=1;
int32_t demoplay_diffs=1;
int32_t demorec_seeds_cvar=1;
int32_t demoplay_showsync=1;
static int32_t demorec_seeds=1, demo_hasseeds;
////////////////////
int32_t G_PlaybackDemo(void)
{
int32_t bigi, initsyncofs = 0, lastsyncofs = 0, lastsynctic = 0, lastsyncclock = 0;
int32_t foundemo = 0, outofsync=0;
static int32_t in_menu = 0;
@ -63,71 +44,57 @@ int32_t G_PlaybackDemo(void)
if (ready2send)
return 0;
RECHECK:
in_menu = g_player[myconnectindex].ps->gm&MODE_MENU;
pub = NUMPAGES;
pus = NUMPAGES;
renderFlushPerms();
if (foundemo == 0)
while (int in_menu = g_player[myconnectindex].ps->gm & MODE_MENU)
{
ud.recstat = 0;
//fadepal(0,0,0, 0,252,28);
drawbackground();
//M_DisplayMenus();
videoNextPage();
//fadepal(0,0,0, 252,0,-28);
ud.reccnt = 0;
}
if (foundemo == 0 || in_menu || inputState.CheckAllInput() || numplayers > 1)
{
FX_StopAllSounds();
M_StartControlPanel(false);
}
ready2send = 0;
bigi = 0;
inputState.ClearAllInput();
while (g_demo_cnt < g_demo_totalCnt || foundemo==0)
{
// Main loop here. It also runs when there's no demo to show,
// so maybe a better name for this function would be
// G_MainLoopWhenNotInGame()?
if (G_FPSLimit())
if (foundemo == 0)
{
ud.recstat = 0;
//fadepal(0,0,0, 0,252,28);
drawbackground();
//M_DisplayMenus();
videoNextPage();
//fadepal(0,0,0, 252,0,-28);
ud.reccnt = 0;
}
if (foundemo == 0 || in_menu || inputState.CheckAllInput() || numplayers > 1)
{
FX_StopAllSounds();
M_StartControlPanel(false);
}
ready2send = 0;
inputState.ClearAllInput();
while (true)
{
// Main loop here. It also runs when there's no demo to show,
// so maybe a better name for this function would be
// G_MainLoopWhenNotInGame()?
if (foundemo == 0)
{
drawbackground();
}
if ((g_player[myconnectindex].ps->gm&MODE_MENU) && (g_player[myconnectindex].ps->gm&MODE_EOL))
if ((g_player[myconnectindex].ps->gm & MODE_MENU) && (g_player[myconnectindex].ps->gm & MODE_EOL))
{
videoNextPage();
goto RECHECK;
break;
}
else if (g_player[myconnectindex].ps->gm&MODE_TYPE)
else if (g_player[myconnectindex].ps->gm & MODE_TYPE)
{
Net_SendMessage();
if ((g_player[myconnectindex].ps->gm&MODE_TYPE) != MODE_TYPE)
if ((g_player[myconnectindex].ps->gm & MODE_TYPE) != MODE_TYPE)
{
g_player[myconnectindex].ps->gm = 0;
M_StartControlPanel(false);
}
M_StartControlPanel(false);
}
}
else
{
//if (ud.recstat != 2)
//M_DisplayMenus();
if ((g_netServer || ud.multimode > 1))// && !Menu_IsTextInput(m_currentMenu))
{
ControlInfo noshareinfo;
@ -140,31 +107,22 @@ RECHECK:
if (VOLUMEONE)
{
if ((g_player[myconnectindex].ps->gm&MODE_MENU) == 0)
rotatesprite_fs((320-50)<<16, 9<<16, 65536L, 0, TILE_BETAVERSION, 0, 0, 2+8+16+128);
if ((g_player[myconnectindex].ps->gm & MODE_MENU) == 0)
rotatesprite_fs((320 - 50) << 16, 9 << 16, 65536L, 0, TILE_BETAVERSION, 0, 0, 2 + 8 + 16 + 128);
}
videoNextPage();
G_HandleAsync();
if (g_player[myconnectindex].ps->gm == MODE_GAME)
{
// user wants to play a game, quit showing demo!
return 0;
}
}
G_HandleAsync();
if (g_player[myconnectindex].ps->gm == MODE_GAME)
{
// user wants to play a game, quit showing demo!
return 0;
}
ud.multimode = numplayers; // fixes 2 infinite loops after watching demo
}
ud.multimode = numplayers; // fixes 2 infinite loops after watching demo
// if we're in the menu, try next demo immediately
if (g_player[myconnectindex].ps->gm&MODE_MENU)
goto RECHECK;
// finished playing a demo and not in menu:
// return so that e.g. the title can be shown
return 1;
}

View file

@ -30,7 +30,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "osdcmds.h"
#include "net.h"
#include "savegame.h"
#include "demo.h"
#include "cheats.h"
#include "sbar.h"

View file

@ -24,7 +24,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "ns.h" // Must come before everything else!
#include "cheats.h"
#include "demo.h" // g_firstDemoFile[]
#include "duke3d.h"
#include "osdcmds.h"
#include "savegame.h"

View file

@ -22,7 +22,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "ns.h" // Must come before everything else!
#include "duke3d.h"
#include "demo.h"
#include "d_event.h"
#include "gamevar.h"

View file

@ -22,7 +22,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "ns.h" // Must come before everything else!
#include "duke3d.h"
#include "demo.h"
#include "savegame.h"
#include "statistics.h"
#include "menu/menu.h"

View file

@ -26,7 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "screens.h"
#include "sbar.h"
#include "demo.h"
#include "mdsprite.h"
#include "gamecvars.h"
#include "menu/menu.h"
@ -318,7 +317,7 @@ void G_DisplayRest(int32_t smoothratio)
if (ud.pause_on == 1 && (g_player[myconnectindex].ps->gm & MODE_MENU) == 0)
fi.PrintPaused();
mdpause = (ud.pause_on || (ud.recstat==2 && (g_demo_paused && g_demo_goalCnt==0)) || (g_player[myconnectindex].ps->gm&MODE_MENU && numplayers < 2));
mdpause = (ud.pause_on || (g_player[myconnectindex].ps->gm&MODE_MENU && numplayers < 2));
Net_DisplaySyncMsg();