Skip to content
Snippets Groups Projects
Commit 6371c5df authored by rswindell's avatar rswindell
Browse files

Implemented support for multiple-answer polls/ballots.

parent 5a853927
No related branches found
No related tags found
No related merge requests found
...@@ -1218,18 +1218,20 @@ int sbbs_t::scanposts(uint subnum, long mode, const char *find) ...@@ -1218,18 +1218,20 @@ int sbbs_t::scanposts(uint subnum, long mode, const char *find)
ZERO_VAR(vote); ZERO_VAR(vote);
if(msg.hdr.type == SMB_MSG_TYPE_POLL) { if(msg.hdr.type == SMB_MSG_TYPE_POLL) {
unsigned answers=0; str_list_t answers = NULL;
for(i=0; i<msg.total_hfields; i++) { for(i=0; i<msg.total_hfields; i++) {
if(msg.hfield[i].type != SMB_POLL_ANSWER) if(msg.hfield[i].type == SMB_POLL_ANSWER)
continue; strListPush(&answers, (char*)msg.hfield_dat[i]);
uselect(1, answers++, msg.subj, (char*)msg.hfield_dat[i], NULL); }
} SAFEPRINTF(str, text[BallotHdr], msg.subj);
i = uselect(0, 0, NULL, NULL, NULL); i = mselect(str, answers, msg.hdr.votes ? msg.hdr.votes : 1, text[BallotAnswerFmt]
if(i < 0) { ,text[PollAnswerChecked], nulstr, text[BallotVoteWhich]);
strListFree(&answers);
if(i <= 0) {
domsg = false; domsg = false;
break; break;
} }
vote.hdr.votes = (1<<i); vote.hdr.votes = i;
vote.hdr.attr = MSG_VOTE; vote.hdr.attr = MSG_VOTE;
notice = text[PollVoteNotice]; notice = text[PollVoteNotice];
} else { } else {
......
...@@ -801,6 +801,9 @@ enum { ...@@ -801,6 +801,9 @@ enum {
,PollAnswerNumber ,PollAnswerNumber
,PollAnswerFmt ,PollAnswerFmt
,PollAnswerChecked ,PollAnswerChecked
,BallotHdr
,BallotAnswerFmt
,BallotVoteWhich
,TOTAL_TEXT ,TOTAL_TEXT
}; };
......
...@@ -1307,4 +1307,8 @@ const char * const text_defaults[TOTAL_TEXT]={ ...@@ -1307,4 +1307,8 @@ const char * const text_defaults[TOTAL_TEXT]={
,"\x01\x6e\x01\x63\x01\x68\x25\x32\x75\x01\x6e\x01\x63\x3a\x20" // 788 PollAnswerNumber ,"\x01\x6e\x01\x63\x01\x68\x25\x32\x75\x01\x6e\x01\x63\x3a\x20" // 788 PollAnswerNumber
,"\x25\x2d\x2a\x2e\x2a\x73\x20\x5b\x25\x2d\x34\x75\x20\x25\x33\x2e\x30\x66\x25\x25\x5d" // 789 PollAnswerFmt ,"\x25\x2d\x2a\x2e\x2a\x73\x20\x5b\x25\x2d\x34\x75\x20\x25\x33\x2e\x30\x66\x25\x25\x5d" // 789 PollAnswerFmt
,"\x20\xfb" // 790 PollAnswerChecked ,"\x20\xfb" // 790 PollAnswerChecked
,"\x01\x6e\x01\x6c\x01\x67\x42\x61\x6c\x6c\x6f\x74\x20\x66\x6f\x72\x20\x01\x68\x25\x73\x0d\x0a\x0d\x0a" // 791 BallotHdr
,"\x01\x6e\x01\x63\x01\x68\x25\x32\x75\x01\x6e\x01\x63\x3a\x20\x25\x2d\x2a\x2e\x2a\x73\x20\x01\x68\x25\x73\x0d\x0a" // 792 BallotAnswerFmt
,"\x0d\x0a\x54\x6f\x67\x67\x6c\x65\x20\x77\x68\x69\x63\x68\x20\x76\x6f\x74\x65\x20\x28\x75\x70\x20\x74\x6f\x20\x25\x75\x29\x2c\x20"
"\x7e\x51\x75\x69\x74\x20\x6f\x72\x20\x5b\x43\x61\x73\x74\x5d\x3a\x20" // 793 BallotVoteWhich
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment