Skip to content

Commit

Permalink
workaround for message number saving (fixes TokTok#961)
Browse files Browse the repository at this point in the history
  • Loading branch information
zugz committed Dec 30, 2019
1 parent c135f00 commit e262210
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions toxcore/group.c
Original file line number Diff line number Diff line change
Expand Up @@ -3209,6 +3209,11 @@ static uint32_t saved_conf_size(const Group_c *g)
return len;
}

/* Save a future message number; the save will remain valid until we have sent
* this many more messages. */
#define SAVE_OFFSET_MESSAGE_NUMBER (1 << 16)
#define SAVE_OFFSET_LOSSY_MESSAGE_NUMBER (1 << 13)

static uint8_t *save_conf(const Group_c *g, uint8_t *data)
{
*data = g->type;
Expand All @@ -3217,10 +3222,10 @@ static uint8_t *save_conf(const Group_c *g, uint8_t *data)
memcpy(data, g->id, GROUP_ID_LENGTH);
data += GROUP_ID_LENGTH;

host_to_lendian_bytes32(data, g->message_number);
host_to_lendian_bytes32(data, g->message_number + SAVE_OFFSET_MESSAGE_NUMBER);
data += sizeof(uint32_t);

host_to_lendian_bytes16(data, g->lossy_message_number);
host_to_lendian_bytes16(data, g->lossy_message_number + SAVE_OFFSET_LOSSY_MESSAGE_NUMBER);
data += sizeof(uint16_t);

host_to_lendian_bytes16(data, g->peer_number);
Expand Down

0 comments on commit e262210

Please sign in to comment.