Commit 6371c5df authored by rswindell's avatar rswindell
Browse files

Implemented support for multiple-answer polls/ballots.

parent 5a853927
......@@ -1218,18 +1218,20 @@ int sbbs_t::scanposts(uint subnum, long mode, const char *find)
ZERO_VAR(vote);
if(msg.hdr.type == SMB_MSG_TYPE_POLL) {
unsigned answers=0;
str_list_t answers = NULL;
for(i=0; i<msg.total_hfields; i++) {
if(msg.hfield[i].type != SMB_POLL_ANSWER)
continue;
uselect(1, answers++, msg.subj, (char*)msg.hfield_dat[i], NULL);
if(msg.hfield[i].type == SMB_POLL_ANSWER)
strListPush(&answers, (char*)msg.hfield_dat[i]);
}
i = uselect(0, 0, NULL, NULL, NULL);
if(i < 0) {
SAFEPRINTF(str, text[BallotHdr], msg.subj);
i = mselect(str, answers, msg.hdr.votes ? msg.hdr.votes : 1, text[BallotAnswerFmt]
,text[PollAnswerChecked], nulstr, text[BallotVoteWhich]);
strListFree(&answers);
if(i <= 0) {
domsg = false;
break;
}
vote.hdr.votes = (1<<i);
vote.hdr.votes = i;
vote.hdr.attr = MSG_VOTE;
notice = text[PollVoteNotice];
} else {
......
......@@ -801,6 +801,9 @@ enum {
,PollAnswerNumber
,PollAnswerFmt
,PollAnswerChecked
,BallotHdr
,BallotAnswerFmt
,BallotVoteWhich
,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
,"\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
,"\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
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment