diff options
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/Messenger.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index fa11704c..48a79aa0 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -1328,29 +1328,24 @@ int file_seek(const Messenger *m, int32_t friendnumber, uint32_t filenumber, uin | |||
1328 | return -2; | 1328 | return -2; |
1329 | } | 1329 | } |
1330 | 1330 | ||
1331 | uint32_t temp_filenum; | 1331 | if (filenumber < (1 << 16)) { |
1332 | uint8_t send_receive, file_number; | 1332 | // Not receiving. |
1333 | |||
1334 | if (filenumber >= (1 << 16)) { | ||
1335 | send_receive = 1; | ||
1336 | temp_filenum = (filenumber >> 16) - 1; | ||
1337 | } else { | ||
1338 | return -4; | 1333 | return -4; |
1339 | } | 1334 | } |
1340 | 1335 | ||
1336 | uint32_t temp_filenum = (filenumber >> 16) - 1; | ||
1337 | |||
1341 | if (temp_filenum >= MAX_CONCURRENT_FILE_PIPES) { | 1338 | if (temp_filenum >= MAX_CONCURRENT_FILE_PIPES) { |
1342 | return -3; | 1339 | return -3; |
1343 | } | 1340 | } |
1344 | 1341 | ||
1345 | file_number = temp_filenum; | 1342 | #ifdef TOX_DEBUG |
1346 | 1343 | assert(temp_filenum <= UINT8_MAX); | |
1347 | struct File_Transfers *ft; | 1344 | #endif |
1345 | uint8_t file_number = temp_filenum; | ||
1348 | 1346 | ||
1349 | if (send_receive) { | 1347 | // We're always receiving at this point. |
1350 | ft = &m->friendlist[friendnumber].file_receiving[file_number]; | 1348 | struct File_Transfers *ft = &m->friendlist[friendnumber].file_receiving[file_number]; |
1351 | } else { | ||
1352 | ft = &m->friendlist[friendnumber].file_sending[file_number]; | ||
1353 | } | ||
1354 | 1349 | ||
1355 | if (ft->status == FILESTATUS_NONE) { | 1350 | if (ft->status == FILESTATUS_NONE) { |
1356 | return -3; | 1351 | return -3; |
@@ -1367,7 +1362,7 @@ int file_seek(const Messenger *m, int32_t friendnumber, uint32_t filenumber, uin | |||
1367 | uint64_t sending_pos = position; | 1362 | uint64_t sending_pos = position; |
1368 | host_to_net((uint8_t *)&sending_pos, sizeof(sending_pos)); | 1363 | host_to_net((uint8_t *)&sending_pos, sizeof(sending_pos)); |
1369 | 1364 | ||
1370 | if (send_file_control_packet(m, friendnumber, send_receive, file_number, FILECONTROL_SEEK, (uint8_t *)&sending_pos, | 1365 | if (send_file_control_packet(m, friendnumber, 1, file_number, FILECONTROL_SEEK, (uint8_t *)&sending_pos, |
1371 | sizeof(sending_pos))) { | 1366 | sizeof(sending_pos))) { |
1372 | ft->transferred = position; | 1367 | ft->transferred = position; |
1373 | } else { | 1368 | } else { |