Remove undecided

This commit is contained in:
Emil 2023-08-17 06:16:55 -06:00
parent cc1cd29c93
commit f0026bd5e3
No known key found for this signature in database
GPG Key ID: 5432DB986FDBCF8A

View File

@ -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', use y/n", *arg); goto stop;
default: ircmsg(creds.channel, "Unknown vote meaning: '%c'", *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" : "REJECTED");
MAX(yes,no) ? "PASSED" :
yes == no ? "REJECTED" : " UNDECIDED");
vote_on = 0; vote_on = 0;
} }
} }