Support netreplays in titledemos

TDEMO###, where ### is a number from 1 to 255.
This commit is contained in:
fickleheart 2019-02-17 13:13:45 -06:00
parent a6dff0a324
commit c260e27cd9
5 changed files with 75 additions and 32 deletions

View file

@ -151,8 +151,8 @@ extern FILE *logstream;
#else
#define VERSION 100 // Game version
#define SUBVERSION 3 // more precise version number
#define VERSIONSTRING "v1.0.3"
#define VERSIONSTRINGW L"v1.0.3"
#define VERSIONSTRING "v1.0.3 Netreplays"
#define VERSIONSTRINGW L"v1.0.3 Netreplays"
// Hey! If you change this, add 1 to the MODVERSION below!
// Otherwise we can't force updates!
#endif

View file

@ -1024,11 +1024,28 @@ void F_TitleScreenTicker(boolean run)
// is it time?
if (!(--demoIdleLeft))
{
static boolean use_netreplay = false;
char dname[9];
lumpnum_t l;
const char *mapname;
UINT8 numstaff;
if ((use_netreplay = !use_netreplay))
{
numstaff = 1;
while ((l = W_CheckNumForName(va("TDEMO%03u", numstaff))) != LUMPERROR)
numstaff++;
numstaff--;
if (numstaff)
{
numstaff = M_RandomKey(numstaff)+1;
snprintf(dname, 9, "TDEMO%03u", numstaff);
goto loadreplay;
}
}
// prevent console spam if failed
demoIdleLeft = demoIdleTime;
@ -1079,6 +1096,7 @@ void F_TitleScreenTicker(boolean run)
return;
}*/
loadreplay:
titledemo = fromtitledemo = true;
demo_ignorefiles = true;
demo_loadfiles = false;

View file

@ -6653,7 +6653,7 @@ void G_DoPlayDemo(char *defdemoname)
{
if (titledemo) // Titledemos should always play and ought to always be compatible with whatever wadlist is running.
G_SkipDemoExtraFiles(&demo_p);
if (demo_loadfiles)
else if (demo_loadfiles)
G_LoadDemoExtraFiles(&demo_p);
else if (demo_ignorefiles)
G_SkipDemoExtraFiles(&demo_p);
@ -6839,6 +6839,7 @@ void G_DoPlayDemo(char *defdemoname)
if (multiplayer) {
boolean spectator;
UINT8 slots[MAXPLAYERS], numslots = 0;
// Load players that were in-game when the map started
p = READUINT8(demo_p);
@ -6850,6 +6851,7 @@ void G_DoPlayDemo(char *defdemoname)
spectator = true;
p &= ~DEMO_SPECTATOR;
}
slots[numslots] = p; numslots++;
if (!playeringame[displayplayer] || players[displayplayer].spectator)
displayplayer = consoleplayer = secondarydisplayplayer = thirddisplayplayer = fourthdisplayplayer = p;
@ -6895,6 +6897,17 @@ void G_DoPlayDemo(char *defdemoname)
}
splitscreen = 0;
if (titledemo)
{
splitscreen = min(min(3, numslots-1), max(0, M_RandomKey(6)-1)); // Bias toward 1p and 4p views
for (p = 0; p <= splitscreen; p++)
G_ResetView(p+1, slots[M_RandomKey(numslots)], false);
CONS_Printf("%d - %d %d %d %d\n", splitscreen, displayplayer, secondarydisplayplayer, thirddisplayplayer, fourthdisplayplayer);
}
R_ExecuteSetViewSize();
}
@ -7438,7 +7451,7 @@ boolean G_CheckDemoStatus(void)
if (singledemo)
I_Quit();
if (multiplayer)
if (multiplayer && !titledemo)
G_ExitLevel();
else
{

View file

@ -8107,19 +8107,12 @@ static void K_drawInput(void)
if (timeinmap < 113)
{
INT32 count = ((INT32)(timeinmap) - 105);
offs = (titledemo ? 128 : 64);
offs = 64;
while (count-- > 0)
offs >>= 1;
x += offs;
}
if (titledemo)
{
V_DrawTinyScaledPatch(x-54, 128, splitflags, W_CachePatchName("TTKBANNR", PU_CACHE));
V_DrawTinyScaledPatch(x-54, 128+25, splitflags, W_CachePatchName("TTKART", PU_CACHE));
return;
}
#define BUTTW 8
#define BUTTH 11
@ -8413,7 +8406,7 @@ void K_drawKartHUD(void)
&& comeback
&& stplyr->playerstate == PST_LIVE)));
if (!battlefullscreen || splitscreen)
if (!titledemo && (!battlefullscreen || splitscreen))
{
// Draw the CHECK indicator before the other items, so it's overlapped by everything else
if (cv_kartcheck.value && !splitscreen && !players[displayplayer].exiting)
@ -8428,7 +8421,7 @@ void K_drawKartHUD(void)
K_drawKartWanted();
}
if (cv_kartminimap.value && !titledemo)
if (cv_kartminimap.value)
{
#ifdef HAVE_BLUA
if (LUA_HudEnabled(hud_minimap))
@ -8469,26 +8462,45 @@ void K_drawKartHUD(void)
}
if (!stplyr->spectator) // Bottom of the screen elements, don't need in spectate mode
{
if (G_RaceGametype()) // Race-only elements
{
if (!titledemo)
{
// Draw the lap counter
#ifdef HAVE_BLUA
if (LUA_HudEnabled(hud_gametypeinfo))
#endif
K_drawKartLaps();
{
if (titledemo) // Draw title logo instead in titledemos
{
INT32 x = BASEVIDWIDTH - 32, y = 128, offs;
if (splitscreen == 3)
{
x = BASEVIDWIDTH/2 + 10;
y = BASEVIDHEIGHT/2 - 30;
}
if (!splitscreen)
{
// Draw the speedometer
// TODO: Make a better speedometer.
if (timeinmap < 113)
{
INT32 count = ((INT32)(timeinmap) - 104);
offs = 256;
while (count-- > 0)
offs >>= 1;
x += offs;
}
V_DrawTinyScaledPatch(x-54, y, 0, W_CachePatchName("TTKBANNR", PU_CACHE));
V_DrawTinyScaledPatch(x-54, y+25, 0, W_CachePatchName("TTKART", PU_CACHE));
}
else if (G_RaceGametype()) // Race-only elements
{
// Draw the lap counter
#ifdef HAVE_BLUA
if (LUA_HudEnabled(hud_speedometer))
if (LUA_HudEnabled(hud_gametypeinfo))
#endif
K_drawKartSpeedometer();
}
K_drawKartLaps();
if (!splitscreen)
{
// Draw the speedometer
// TODO: Make a better speedometer.
#ifdef HAVE_BLUA
if (LUA_HudEnabled(hud_speedometer))
#endif
K_drawKartSpeedometer();
}
if (isfreeplay)

View file

@ -1907,7 +1907,7 @@ static void ST_overlayDrawer(void)
V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-32, V_ALLOWLOWERCASE, player_names[stplyr-players]);
}
}
else
else if (!titledemo)
{
if (!splitscreen)