Skip to content

Commit

Permalink
Fix wrong wrap-around introduced by last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dl1jbe committed Jun 14, 2017
1 parent a3efd14 commit ffaadbf
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions src/callinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ int autosend(void);
int plain_number(char *str);
void handle_bandswitch(int direction);

#define UP +1
#define DOWN -1
#define BAND_UP +1
#define BAND_DOWN -1

extern int no_arrows;
extern char hiscall[];
Expand Down Expand Up @@ -368,7 +368,7 @@ char callinput(void)
if (*hiscall != '\0') {
calledit();
} else {
handle_bandswitch(DOWN);
handle_bandswitch(BAND_DOWN);
}

break;
Expand All @@ -377,7 +377,7 @@ char callinput(void)
// Right Arrow, band up when call field is empty.
case KEY_RIGHT:
{
handle_bandswitch(UP);
handle_bandswitch(BAND_UP);
break;
}

Expand Down Expand Up @@ -451,7 +451,7 @@ char callinput(void)
clear_display();
}
} else { // trlog compatible, band switch
handle_bandswitch(DOWN);
handle_bandswitch(BAND_DOWN);
}
x = -1;

Expand Down Expand Up @@ -746,7 +746,7 @@ char callinput(void)
case 226:
{
if (ctcomp == 0) {
handle_bandswitch(UP);
handle_bandswitch(BAND_UP);
}
break;
}
Expand Down Expand Up @@ -1384,15 +1384,7 @@ void send_bandswitch(int freq)
}
}

/** handle bandswitch from keyboard
*
**/
void handle_bandswitch(int direction) {
// make sure call field is empty and arrows are enabled
if (*hiscall != '\0' || no_arrows) {
return;
}

static void next_band(int direction) {
bandinx += direction;

if (bandinx < 0) {
Expand All @@ -1402,10 +1394,22 @@ void handle_bandswitch(int direction) {
if (bandinx >= NBANDS) {
bandinx = 0;
}
}

/** handle bandswitch from keyboard
*
**/
void handle_bandswitch(int direction) {
// make sure call field is empty and arrows are enabled
if (*hiscall != '\0' || no_arrows) {
return;
}

next_band(direction);

if (contest == 1 && dxped == 0) {
while (IsWarcIndex(bandinx)) { /* loop till next contest band */
bandinx += direction;
next_band(direction);
}
}

Expand Down

0 comments on commit ffaadbf

Please sign in to comment.