mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Merge branch 'altmusic-demo-consis' into 'master'
(demo v9) Demo save unlocks and mapmusrng Closes #1004 and #1093 See merge request KartKrew/Kart!1981
This commit is contained in:
commit
8f795d7b5f
3 changed files with 58 additions and 12 deletions
|
|
@ -110,7 +110,7 @@ demoghost *ghosts = NULL;
|
||||||
// DEMO RECORDING
|
// DEMO RECORDING
|
||||||
//
|
//
|
||||||
|
|
||||||
#define DEMOVERSION 0x0008
|
#define DEMOVERSION 0x0009
|
||||||
#define DEMOHEADER "\xF0" "KartReplay" "\x0F"
|
#define DEMOHEADER "\xF0" "KartReplay" "\x0F"
|
||||||
|
|
||||||
#define DF_ATTACKMASK (ATTACKING_TIME|ATTACKING_LAP|ATTACKING_SPB) // This demo contains time/lap data
|
#define DF_ATTACKMASK (ATTACKING_TIME|ATTACKING_LAP|ATTACKING_SPB) // This demo contains time/lap data
|
||||||
|
|
@ -2205,6 +2205,18 @@ void G_BeginRecording(void)
|
||||||
WRITEUINT8(demobuf.p, grandprixinfo.eventmode);
|
WRITEUINT8(demobuf.p, grandprixinfo.eventmode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save netUnlocked from actual unlocks
|
||||||
|
// (netUnlocked is used in m_cond.c M_CheckNetUnlockByID)
|
||||||
|
WRITEUINT32(demobuf.p, MAXUNLOCKABLES);
|
||||||
|
for (size_t unlockindex = 0; unlockindex < MAXUNLOCKABLES; unlockindex++)
|
||||||
|
{
|
||||||
|
UINT8 unlock = gamedata->unlocked[unlockindex];
|
||||||
|
WRITEUINT8(demobuf.p, unlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save "mapmusrng" used for altmusic selection
|
||||||
|
WRITEUINT8(demobuf.p, mapmusrng);
|
||||||
|
|
||||||
// Now store some info for each in-game player
|
// Now store some info for each in-game player
|
||||||
|
|
||||||
// Lat' 12/05/19: Do note that for the first game you load, everything that gets saved here is total garbage;
|
// Lat' 12/05/19: Do note that for the first game you load, everything that gets saved here is total garbage;
|
||||||
|
|
@ -3163,6 +3175,21 @@ void G_DoPlayDemo(const char *defdemoname)
|
||||||
grandprixinfo.eventmode = static_cast<gpEvent_e>(READUINT8(demobuf.p));
|
grandprixinfo.eventmode = static_cast<gpEvent_e>(READUINT8(demobuf.p));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load unlocks into netUnlocked
|
||||||
|
{
|
||||||
|
UINT32 unlockables = READUINT32(demobuf.p);
|
||||||
|
UINT32 unlocksread = std::min<UINT32>(unlockables, MAXUNLOCKABLES);
|
||||||
|
for (size_t i = 0; i < unlocksread; i++)
|
||||||
|
{
|
||||||
|
netUnlocked[i] = static_cast<boolean>(READUINT8(demobuf.p));
|
||||||
|
}
|
||||||
|
// skip remainder
|
||||||
|
demobuf.p += unlockables - unlocksread;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load "mapmusrng" used for altmusic selection
|
||||||
|
mapmusrng = READUINT8(demobuf.p);
|
||||||
|
|
||||||
// Sigh ... it's an empty demo.
|
// Sigh ... it's an empty demo.
|
||||||
if (*demobuf.p == DEMOMARKER)
|
if (*demobuf.p == DEMOMARKER)
|
||||||
{
|
{
|
||||||
|
|
@ -3911,11 +3938,12 @@ boolean G_CheckDemoStatus(void)
|
||||||
G_FinishExitLevel();
|
G_FinishExitLevel();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
UINT8 wasmodeattacking = modeattacking;
|
||||||
G_StopDemo();
|
G_StopDemo();
|
||||||
|
|
||||||
if (timedemo_quit)
|
if (timedemo_quit)
|
||||||
COM_ImmedExecute("quit");
|
COM_ImmedExecute("quit");
|
||||||
else if (modeattacking)
|
else if (wasmodeattacking)
|
||||||
M_EndModeAttackRun();
|
M_EndModeAttackRun();
|
||||||
else if (demo.attract == DEMO_ATTRACT_CREDITS)
|
else if (demo.attract == DEMO_ATTRACT_CREDITS)
|
||||||
F_ContinueCredits();
|
F_ContinueCredits();
|
||||||
|
|
|
||||||
|
|
@ -3270,7 +3270,7 @@ boolean M_CheckNetUnlockByID(UINT16 unlockid)
|
||||||
return true; // default permit
|
return true; // default permit
|
||||||
}
|
}
|
||||||
|
|
||||||
if (netgame)
|
if (netgame || demo.playback)
|
||||||
{
|
{
|
||||||
return netUnlocked[unlockid];
|
return netUnlocked[unlockid];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8177,20 +8177,33 @@ void P_ResetLevelMusic(void)
|
||||||
{
|
{
|
||||||
UINT8 idx = 0;
|
UINT8 idx = 0;
|
||||||
|
|
||||||
if (mapheaderinfo[gamemap-1]->musname_size > 1)
|
mapheader_t* mapheader = mapheaderinfo[gamemap - 1];
|
||||||
|
|
||||||
|
// To keep RNG in sync, we will always pull from RNG, even if unused
|
||||||
|
UINT32 random = P_Random(PR_MUSICSELECT);
|
||||||
|
|
||||||
|
if (demo.playback)
|
||||||
|
{
|
||||||
|
// mapmusrng has already been set by the demo; just make sure it's valid
|
||||||
|
if (mapmusrng >= mapheader->musname_size)
|
||||||
|
{
|
||||||
|
mapmusrng = 0;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mapheader->musname_size > 1)
|
||||||
{
|
{
|
||||||
UINT8 tempmapmus[MAXMUSNAMES], tempmapmus_size = 1, i;
|
UINT8 tempmapmus[MAXMUSNAMES], tempmapmus_size = 1, i;
|
||||||
|
|
||||||
tempmapmus[0] = 0;
|
tempmapmus[0] = 0;
|
||||||
|
|
||||||
for (i = 1; i < mapheaderinfo[gamemap-1]->musname_size; i++)
|
for (i = 1; i < mapheader->musname_size; i++)
|
||||||
{
|
{
|
||||||
if (mapheaderinfo[gamemap-1]->cache_muslock[i-1] < MAXUNLOCKABLES
|
if (mapheader->cache_muslock[i-1] < MAXUNLOCKABLES
|
||||||
&& !M_CheckNetUnlockByID(mapheaderinfo[gamemap-1]->cache_muslock[i-1]))
|
&& !M_CheckNetUnlockByID(mapheader->cache_muslock[i-1]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//CONS_Printf("TEST - %u\n", i);
|
|
||||||
|
|
||||||
tempmapmus[tempmapmus_size++] = i;
|
tempmapmus[tempmapmus_size++] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -8204,9 +8217,8 @@ void P_ResetLevelMusic(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
idx = P_RandomKey(PR_MUSICSELECT, tempmapmus_size);
|
idx = random % tempmapmus_size;
|
||||||
}
|
}
|
||||||
//CONS_Printf("Rolled position %u, maps to %u\n", mapmusrng, tempmapmus[mapmusrng]);
|
|
||||||
idx = tempmapmus[idx];
|
idx = tempmapmus[idx];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -8216,7 +8228,13 @@ void P_ResetLevelMusic(void)
|
||||||
|
|
||||||
void P_LoadLevelMusic(void)
|
void P_LoadLevelMusic(void)
|
||||||
{
|
{
|
||||||
const char *music = mapheaderinfo[gamemap-1]->musname[mapmusrng];
|
mapheader_t* mapheader = mapheaderinfo[gamemap-1];
|
||||||
|
const char *music = mapheader->musname[0];
|
||||||
|
|
||||||
|
if (mapmusrng < mapheader->musname_size)
|
||||||
|
{
|
||||||
|
music = mapheader->musname[mapmusrng];
|
||||||
|
}
|
||||||
|
|
||||||
if (gametyperules & GTR_NOPOSITION || modeattacking != ATTACKING_NONE)
|
if (gametyperules & GTR_NOPOSITION || modeattacking != ATTACKING_NONE)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue