Skip to content

Commit

Permalink
Write private configstrings and layout to snapshots.
Browse files Browse the repository at this point in the history
  • Loading branch information
skullernet authored and res2k committed Jan 25, 2024
1 parent 53f786e commit 8665daa
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions src/server/mvd/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ static void demo_emit_snapshot(mvd_t *mvd)
int64_t pos;
char *from, *to;
size_t len;
int i;
int i, bits;

if (mvd_snaps->integer <= 0)
return;
Expand Down Expand Up @@ -597,7 +597,39 @@ static void demo_emit_snapshot(mvd_t *mvd)
MSG_WriteByte(0);
}

// TODO: write private layouts/configstrings
// write private configstrings
for (i = 0; i < mvd->maxclients; i++) {
mvd_player_t *player = &mvd->players[i];
mvd_cs_t *cs;

if (!player->configstrings)
continue;

len = 0;
for (cs = player->configstrings; cs; cs = cs->next)
len += 4 + strlen(cs->string);

bits = (len >> 8) & 7;
MSG_WriteByte(mvd_unicast | (bits << SVCMD_BITS));
MSG_WriteByte(len & 255);
MSG_WriteByte(i);
for (cs = player->configstrings; cs; cs = cs->next) {
MSG_WriteByte(svc_configstring);
MSG_WriteShort(cs->index);
MSG_WriteString(cs->string);
}
}

// write layout
if (mvd->clientNum != -1) {
len = 2 + strlen(mvd->layout);
bits = (len >> 8) & 7;
MSG_WriteByte(mvd_unicast | (bits << SVCMD_BITS));
MSG_WriteByte(len & 255);
MSG_WriteByte(mvd->clientNum);
MSG_WriteByte(svc_layout);
MSG_WriteString(mvd->layout);
}

snap = MVD_Malloc(sizeof(*snap) + msg_write.cursize - 1);
snap->framenum = mvd->framenum;
Expand Down Expand Up @@ -2363,6 +2395,9 @@ static void MVD_Seek_f(void)
MVD_WriteStringList(client, client->target->configstrings);
else if (mvd->dummy)
MVD_WriteStringList(client, mvd->dummy->configstrings);

if (client->layout_type == LAYOUT_SCORES)
client->layout_time = 0;
}

// ouch
Expand Down

0 comments on commit 8665daa

Please sign in to comment.