Pārlūkot izejas kodu

Remove undecided

master
Emil pirms 9 mēnešiem
vecāks
revīzija
f0026bd5e3
Šim parakstam datu bāzē netika atrasta zināma atslēga GPG atslēgas ID: 5432DB986FDBCF8A
1 mainītis faili ar 5 papildinājumiem un 8 dzēšanām
  1. +5
    -8
      src/irc.c

+ 5
- 8
src/irc.c Parādīt failu

@@ -180,7 +180,7 @@ parse_command(char const * cmd)
{ {
size_t i = 0; size_t i = 0;
static int vote_count; static int vote_count;
static int yes, no, undecided;
static int yes, no;
static int vote_on = 0; static int vote_on = 0;
char * msgswp = NULL; char * msgswp = NULL;
/* size_t len = strlen(cmd); */ /* size_t len = strlen(cmd); */
@@ -243,7 +243,7 @@ parse_command(char const * cmd)
{ ircmsg(creds.channel, "%s: " IRC_YELLOW "%d" IRC_STOP, current_username, (rand() % atoi(arg)) + 1); } { ircmsg(creds.channel, "%s: " IRC_YELLOW "%d" IRC_STOP, current_username, (rand() % atoi(arg)) + 1); }
else if (strncmp(cmd, "poll", 4) == 0) else if (strncmp(cmd, "poll", 4) == 0)
{ {
yes = no = undecided = 0;
yes = no = 0;
vote_on = 1; vote_on = 1;
vote_count = atoi(arg); vote_count = atoi(arg);
if (!vote_count) if (!vote_count)
@@ -253,24 +253,21 @@ parse_command(char const * cmd)
} }
else if (strncmp(cmd, "vote", 4) == 0) else if (strncmp(cmd, "vote", 4) == 0)
{ {
fprintf(stderr, "y%d n%d u%d vote_count %d\n", yes, no, undecided, vote_count);
fprintf(stderr, "y%d n%d vote_count %d\n", yes, no, vote_count);
if (vote_on && vote_count) if (vote_on && vote_count)
{ {
switch (*arg) switch (*arg)
{ {
case 'Y': case 'y': ERRMSG("YYY"); ++yes; break; case 'Y': case 'y': ERRMSG("YYY"); ++yes; break;
case 'N': case 'n': ERRMSG("NNN"); ++no; break; case 'N': case 'n': ERRMSG("NNN"); ++no; break;
case 'U': case 'u': ERRMSG("UUU"); ++undecided; break;
default: ircmsg(creds.channel, "Unknown vote meaning: '%c'", *arg); goto stop;
default: ircmsg(creds.channel, "Unknown vote meaning: '%c', use y/n", *arg); goto stop;
} }
if (--vote_count) if (--vote_count)
{ ircmsg(creds.channel, "Votes remaining: %d", vote_count); } { ircmsg(creds.channel, "Votes remaining: %d", vote_count); }
else else
{ {
ircmsg(creds.channel, "poll results: %s", ircmsg(creds.channel, "poll results: %s",
MAX(undecided,MAX(yes,no)) ? "UNDECIDED" :
MAX(yes,no) ? "PASSED" :
yes == no ? "REJECTED" : " UNDECIDED");
MAX(yes,no) ? "PASSED" : "REJECTED");
vote_on = 0; vote_on = 0;
} }
} }