Skip to content

Commit

Permalink
cleanup: Replace a series of if statements with a switch.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Apr 3, 2022
1 parent e49a477 commit 7aa985e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion other/bootstrap_daemon/docker/tox-bootstrapd.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
96618672392dc44a2f0a480f6415380e3fc588ace646345d31a297e80f7c271f /usr/local/bin/tox-bootstrapd
edcbfe0d7fc89dbeb2f0dc9e12a9f1c31d30d4d2978bd7fe0354b0d1a51ed4e8 /usr/local/bin/tox-bootstrapd
31 changes: 19 additions & 12 deletions toxcore/Messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -1266,20 +1266,27 @@ int file_control(const Messenger *m, int32_t friendnumber, uint32_t filenumber,
}

if (send_file_control_packet(m, friendnumber, inbound, file_number, control, nullptr, 0)) {
if (control == FILECONTROL_KILL) {
if (!inbound && (ft->status == FILESTATUS_TRANSFERRING || ft->status == FILESTATUS_FINISHED)) {
// We are actively sending that file, remove from list
--m->friendlist[friendnumber].num_sending_files;
}
switch (control) {
case FILECONTROL_KILL: {
if (!inbound && (ft->status == FILESTATUS_TRANSFERRING || ft->status == FILESTATUS_FINISHED)) {
// We are actively sending that file, remove from list
--m->friendlist[friendnumber].num_sending_files;
}

ft->status = FILESTATUS_NONE;
} else if (control == FILECONTROL_PAUSE) {
ft->paused |= FILE_PAUSE_US;
} else if (control == FILECONTROL_ACCEPT) {
ft->status = FILESTATUS_TRANSFERRING;
ft->status = FILESTATUS_NONE;
break;
}
case FILECONTROL_PAUSE: {
ft->paused |= FILE_PAUSE_US;
break;
}
case FILECONTROL_ACCEPT: {
ft->status = FILESTATUS_TRANSFERRING;

if ((ft->paused & FILE_PAUSE_US) != 0) {
ft->paused ^= FILE_PAUSE_US;
if ((ft->paused & FILE_PAUSE_US) != 0) {
ft->paused ^= FILE_PAUSE_US;
}
break;
}
}
} else {
Expand Down

0 comments on commit 7aa985e

Please sign in to comment.