Write skin/color/name changes to replay

This commit is contained in:
fickleheart 2019-01-27 19:07:30 -06:00
parent 314b2769a9
commit c6248faa30
5 changed files with 135 additions and 0 deletions

View file

@ -1146,6 +1146,7 @@ static void SetPlayerName(INT32 playernum, char *newname)
HU_AddChatText(va("\x82*%s renamed to %s", player_names[playernum], newname), false); HU_AddChatText(va("\x82*%s renamed to %s", player_names[playernum], newname), false);
strcpy(player_names[playernum], newname); strcpy(player_names[playernum], newname);
demo_extradata[playernum] |= DXD_NAME;
} }
} }
else else
@ -1749,6 +1750,7 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
p->skincolor = color % MAXSKINCOLORS; p->skincolor = color % MAXSKINCOLORS;
if (p->mo) if (p->mo)
p->mo->color = (UINT8)p->skincolor; p->mo->color = (UINT8)p->skincolor;
demo_extradata[playernum] |= DXD_COLOR;
// normal player colors // normal player colors
if (server && (p != &players[consoleplayer] && p != &players[secondarydisplayplayer] if (server && (p != &players[consoleplayer] && p != &players[secondarydisplayplayer]

View file

@ -4495,6 +4495,7 @@ char *G_BuildMapTitle(INT32 mapnum)
#define ZT_LATENCY 0x40 #define ZT_LATENCY 0x40
#define DEMOMARKER 0x80 // demoend #define DEMOMARKER 0x80 // demoend
UINT8 demo_extradata[MAXPLAYERS];
static ticcmd_t oldcmd[MAXPLAYERS]; static ticcmd_t oldcmd[MAXPLAYERS];
// For Metal Sonic and time attack ghosts // For Metal Sonic and time attack ghosts
@ -4556,6 +4557,119 @@ ticcmd_t *G_MoveTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n)
return dest; return dest;
} }
void G_ReadDemoExtraData(void)
{
INT32 p, extradata, i;
char name[17];
memset(name, '\0', 17);
p = READUINT8(demo_p);
while (p != 0xFF)
{
extradata = READUINT8(demo_p);
if (extradata & DXD_RESPAWN)
{
if (players[p].mo)
P_DamageMobj(players[p].mo, NULL, NULL, 10000); // Is this how this should work..?
}
if (extradata & DXD_SKIN)
{
CONS_Printf("change skin\n");
// Skin
M_Memcpy(name, demo_p, 16);
demo_p += 16;
SetPlayerSkin(p, name);
}
if (extradata & DXD_COLOR)
{
CONS_Printf("change color\n");
// Color
M_Memcpy(name, demo_p, 16);
demo_p += 16;
for (i = 0; i < MAXSKINCOLORS; i++)
if (!stricmp(KartColor_Names[i], name)) // SRB2kart
{
players[p].skincolor = i;
if (players[p].mo)
players[p].mo->color = i;
break;
}
}
if (extradata & DXD_NAME)
{
// Name
M_Memcpy(player_names[p],demo_p,16);
demo_p += 16;
}
if (extradata & DXD_PLAYSTATE)
{
extradata = READUINT8(demo_p);
// @TODO uhhhhh do something here
}
p = READUINT8(demo_p);
}
}
void G_WriteDemoExtraData(void)
{
INT32 i;
char name[16];
for (i = 0; i < MAXPLAYERS; i++)
{
if (demo_extradata[i])
{
WRITEUINT8(demo_p, i);
WRITEUINT8(demo_p, demo_extradata[i]);
//if (demo_extradata[i] & DXD_RESPAWN) has no extra data
if (demo_extradata[i] & DXD_SKIN)
{
// Skin
memset(name, 0, 16);
strncpy(name, skins[players[i].skin].name, 16);
M_Memcpy(demo_p,name,16);
demo_p += 16;
}
if (demo_extradata[i] & DXD_COLOR)
{
// Color
memset(name, 0, 16);
strncpy(name, KartColor_Names[players[i].skincolor], 16);
M_Memcpy(demo_p,name,16);
demo_p += 16;
}
if (demo_extradata[i] & DXD_NAME)
{
// Name
memset(name, 0, 16);
strncpy(name, player_names[i], 16);
M_Memcpy(demo_p,name,16);
demo_p += 16;
}
if (demo_extradata[i] & DXD_PLAYSTATE)
{
if (!playeringame[i])
WRITEUINT8(demo_p, DXD_PST_LEFT);
else if (players[i].spectator)
WRITEUINT8(demo_p, DXD_PST_SPECTATING);
else
WRITEUINT8(demo_p, DXD_PST_PLAYING);
}
}
demo_extradata[i] = 0;
}
WRITEUINT8(demo_p, 0xFF);
}
void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum) void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum)
{ {
UINT8 ziptic; UINT8 ziptic;
@ -5531,6 +5645,7 @@ void G_BeginRecording(void)
WRITEUINT8(demo_p, 0xFF); // Denote the end of the player listing WRITEUINT8(demo_p, 0xFF); // Denote the end of the player listing
memset(&oldcmd,0,sizeof(oldcmd)); memset(&oldcmd,0,sizeof(oldcmd));
memset(&demo_extradata, 0, sizeof(demo_extradata));
// Lower two lines aren't useful until ghost replays for mp are implemented, but eh // Lower two lines aren't useful until ghost replays for mp are implemented, but eh
memset(&oldghost,0,sizeof(oldghost)); memset(&oldghost,0,sizeof(oldghost));
memset(&ghostext,0,sizeof(ghostext)); memset(&ghostext,0,sizeof(ghostext));

View file

@ -154,7 +154,20 @@ typedef enum
GHC_INVINCIBLE GHC_INVINCIBLE
} ghostcolor_t; } ghostcolor_t;
extern UINT8 demo_extradata[MAXPLAYERS];
#define DXD_RESPAWN 0x01 // "respawn" command in console
#define DXD_SKIN 0x02 // skin changed
#define DXD_NAME 0x04 // name changed
#define DXD_COLOR 0x08 // color changed
#define DXD_PLAYSTATE 0x10 // state changed between playing, spectating, or not in-game
#define DXD_PST_PLAYING 0x01
#define DXD_PST_SPECTATING 0x02
#define DXD_PST_LEFT 0x03
// Record/playback tics // Record/playback tics
void G_ReadDemoExtraData(void);
void G_WriteDemoExtraData(void);
void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum); void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum);
void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum); void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum);
void G_GhostAddThok(void); void G_GhostAddThok(void);

View file

@ -606,6 +606,7 @@ void P_Ticker(boolean run)
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i]) if (playeringame[i])
G_WriteDemoTiccmd(&players[i].cmd, i); G_WriteDemoTiccmd(&players[i].cmd, i);
G_WriteDemoExtraData();
} }
} }
if (demoplayback) if (demoplayback)
@ -617,6 +618,7 @@ void P_Ticker(boolean run)
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i]) if (playeringame[i])
G_ReadDemoTiccmd(&players[i].cmd, i); G_ReadDemoTiccmd(&players[i].cmd, i);
G_ReadDemoExtraData();
} }
} }

View file

@ -2713,6 +2713,9 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum)
if (player->mo) if (player->mo)
P_SetScale(player->mo, player->mo->scale); P_SetScale(player->mo, player->mo->scale);
demo_extradata[playernum] |= DXD_SKIN;
return; return;
} }