Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/q2proto_proto_q2repro.c
Original file line number Diff line number Diff line change
Expand Up @@ -1960,7 +1960,11 @@ static q2proto_error_t q2repro_server_write_spawnbaseline(q2proto_servercontext_
static q2proto_error_t q2repro_server_write_download(q2proto_servercontext_t *context, uintptr_t io_arg,
const q2proto_svc_download_t *download)
{
WRITE_CHECKED(server_write, io_arg, u8, download->compressed ? svc_r1q2_zdownload : svc_download);
// FIX(jackharrhy) previously this was setting the compressed command to svc_r1q2_zdownload,
// which was 22, and q2repro was not a fan of that command, svc_q2repro_zdownload is 35 which
// is in the expected range of commands, so lets write that instead
uint8_t cmd = download->compressed ? svc_q2repro_zdownload : svc_download;
WRITE_CHECKED(server_write, io_arg, u8, cmd);
WRITE_CHECKED(server_write, io_arg, i16, download->size);
WRITE_CHECKED(server_write, io_arg, u8, download->percent);
if (download->size > 0) {
Expand Down Expand Up @@ -2692,6 +2696,12 @@ static q2proto_error_t q2repro_download_data(q2proto_server_download_state_t *st
if (err != Q2P_ERR_SUCCESS)
return err;

// FIX(jackharrhy) q2protoio_deflate_get_data finishes the stream,
// so we need to end it and mark as invalid for the next packet
// (which will create a new stream)
q2protoio_deflate_end(state->deflate_io);
state->deflate_io_valid = false;

svc_download->compressed = true;
svc_download->data = compressed_data;
svc_download->size = compressed_size;
Expand Down
8 changes: 6 additions & 2 deletions src/q2proto_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ q2proto_error_t q2proto_server_write_zpacket(q2proto_servercontext_t *context, q

// Don't double-compress messages...
uint8_t message_type = *(const uint8_t *)packet_data;
if (message_type == svc_r1q2_zpacket)
// FIX(jackharrhy) use context->zpacket_cmd instead of hardcoded
// svc_r1q2_zpacket, which q2repro isn't a fan of
if (message_type == context->zpacket_cmd)
return Q2P_ERR_ALREADY_COMPRESSED;

size_t deflate_io_arg;
Expand All @@ -296,7 +298,9 @@ q2proto_error_t q2proto_server_write_zpacket(q2proto_servercontext_t *context, q
return Q2P_ERR_ALREADY_COMPRESSED;
}

WRITE_CHECKED(server_write, io_arg, u8, svc_r1q2_zpacket);
// FIX(jackharrhy) use context->zpacket_cmd instead of hardcoded
// svc_r1q2_zpacket, which q2repro isn't a fan of
WRITE_CHECKED(server_write, io_arg, u8, context->zpacket_cmd);
WRITE_CHECKED(server_write, io_arg, u16, compressed_len);
WRITE_CHECKED(server_write, io_arg, u16, packet_len);
WRITE_CHECKED(server_write, io_arg, raw, compressed_data, compressed_len, NULL);
Expand Down
Loading