]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/vote.qc
support "cnt" field in items as probability weight for teamed items; works like for...
[divverent/nexuiz.git] / data / qcsrc / server / vote.qc
1 float VoteCheckNasty(string cmd)
2 {
3         if(strstrofs(cmd, ";", 0) >= 0)
4                 return TRUE;
5         if(strstrofs(cmd, "\n", 0) >= 0)
6                 return TRUE;
7         if(strstrofs(cmd, "\r", 0) >= 0)
8                 return TRUE;
9         if(strstrofs(cmd, "$", 0) >= 0)
10                 return TRUE;
11         return FALSE;
12 }
13
14 entity GetKickVoteVictim(string vote, string cmd, entity caller)
15 {
16         float tokens;
17         float n, t;
18         string ns, s;
19         entity e;
20         string reason;
21
22         tokens = tokenize_sane(vote);
23         ns = "";
24
25         if(tokens >= 2)
26                 if(substring(argv(1), 0, 1) == "#")
27                 {
28                         ns = substring(argv(1), 1, 999);
29                         t = 2;
30                 }
31
32         if(tokens >= 3)
33                 if(argv(1) == "#")
34                 {
35                         ns = argv(2);
36                         t = 3;
37                 }
38
39         if(ns != "")
40         {
41                 if(t < tokens)
42                         GetKickVoteVictim_reason = substring(vote, argv_start_index(t), argv_end_index(-1) - argv_start_index(t));
43                 else
44                         GetKickVoteVictim_reason = "";
45
46                 if(cmd != "vdo" || GetKickVoteVictim_reason == "")
47                         reason = "~"; // by convention, ~ prefixes a "unverified" kickban which will not be networked
48                 else
49                         reason = "";
50                 if(caller)
51                         reason = strcat(reason, "player ", strdecolorize(caller.netname));
52                 else
53                         reason = strcat(reason, "console vote");
54                 if(GetKickVoteVictim_reason != "")
55                         reason = strcat(reason, ": ", strdecolorize(GetKickVoteVictim_reason));
56
57                 if not(cvar_value_issafe(reason))
58                         reason = uri_escape(reason);
59
60                 n = stof(ns);
61                 if(ns == ftos(n)) if(n >= 1) if(n <= maxclients)
62                 {
63                         e = edict_num(n);
64                         if(clienttype(e) == CLIENTTYPE_REAL)
65                         {
66                                 GetKickVoteVictim_newcommand = strcat(argv(0), " # ", ns);
67                                 if(argv(0) == "kickban")
68                                 {
69                                         GetKickVoteVictim_newcommand = strcat(GetKickVoteVictim_newcommand, " ", cvar_string("g_ban_default_bantime"), " ", cvar_string("g_ban_default_masksize"), " ", reason);
70                                 }
71                                 else if(argv(0) == "kick")
72                                 {
73                                         GetKickVoteVictim_newcommand = strcat(GetKickVoteVictim_newcommand, " ", reason);
74                                 }
75                                 return e;
76                         }
77                 }
78         }
79
80         print_to(caller, strcat("Usage: ", cmd, " ", argv(0), " #playernumber (as in \"status\")\n"));
81         return world;
82 }
83
84 string RemapVote_display;
85 string RemapVote_vote;
86 float RemapVote(string vote, string cmd, entity e)
87 {
88         float vote_argc;
89         entity victim;
90         vote_argc = tokenize_sane(vote);
91
92         if(!VoteAllowed(argv(0), cmd))
93         {
94                 return FALSE;
95         }
96
97         // VoteAllowed tokenizes!
98         vote_argc = tokenize_sane(vote);
99
100         // remap chmap to gotomap (forces intermission)
101         if(vote_argc < 2)
102                 if(argv(0) == "chmap" || argv(0) == "gotomap" || argv(0) == "kick" || argv(0) == "kickban") // won't work without arguments
103                         return FALSE;
104         if(argv(0) == "chmap")
105         {
106                 vote = strcat("gotomap ", substring(vote, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));
107                 vote_argc = tokenize_sane(vote);
108         }
109         if(argv(0) == "gotomap")
110         {
111                 if(!(vote = ValidateMap(substring(vote, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), e)))
112                         return FALSE;
113                 vote = strcat("gotomap ", vote);
114                 vote_argc = tokenize_sane(vote); // ValidateMap may have done some stuff to it
115         }
116
117         // make kick and kickban votes a bit nicer (and reject them if formatted badly)
118         if(argv(0) == "kick" || argv(0) == "kickban")
119         {
120                 if(!(victim = GetKickVoteVictim(vote, cmd, e)))
121                         return FALSE;
122                 RemapVote_vote = GetKickVoteVictim_newcommand;
123                 RemapVote_display = strcat("^1", RemapVote_vote, " (^7", victim.netname, "^1): ", GetKickVoteVictim_reason);
124         }
125         else
126         {
127                 RemapVote_vote = vote;
128                 RemapVote_display = strzone(strcat("^1", vote));
129         }
130
131         return TRUE;
132 }
133
134 float GameCommand_Vote(string s, entity e) {
135         float argc;
136         argc = tokenize_sane(s);
137         if(argv(0) == "help") {
138                 print_to(e, "  vote COMMANDS ARGUMENTS. See 'vote help' for more info.");
139                 return TRUE;
140         } else if(argv(0) == "vote") {
141                 if(argv(1) == "") {
142                         print_to(e, "^1You have to supply a vote command. See help for more info.");
143                 } else if(argv(1) == "help") {
144                         VoteHelp(e);
145                 } else if(argv(1) == "status") {
146                         if(votecalled) {
147                                 print_to(e, strcat("^7Vote for ", votecalledvote_display, "^7 called by ^7", VoteNetname(votecaller), "^7."));
148                         } else {
149                                 print_to(e, "^1No vote called.");
150                         }
151                 } else if(argv(1) == "call") {
152                         if(!e || cvar("sv_vote_call")) {
153                                 if(cvar("sv_vote_nospectators") && e.classname != "player") {
154                                         print_to(e, "^1Error: Only players can call a vote."); // TODO invent a cvar name for allowing votes by spectators during warmup anyway
155                                 }
156                                 else if(timeoutStatus) { //don't allow a vote call during a timeout
157                                         print_to(e, "^1Error: You can not call a vote while a timeout is active.");
158                                 }
159                                 else if(votecalled) {
160                                         print_to(e, "^1There is already a vote called.");
161                                 } else {
162                                         local string vote;
163                                         vote = VoteParse(s, argc);
164                                         if(vote == "") {
165                                                 print_to(e, "^1Your vote is empty. See help for more info.");
166                                         } else if(e
167                                                 && time < e.vote_next) {
168                                                         print_to(e, strcat("^1You have to wait ^2", ftos(e.vote_next - time), "^1 seconds before you can again call a vote."));
169                                         } else if(VoteCheckNasty(vote)) {
170                                                 print_to(e, "Syntax error in command. See help for more info.");
171                                         } else if(RemapVote(vote, "vcall", e)) {
172                                                 votecalledvote = strzone(RemapVote_vote);
173                                                 votecalledvote_display = strzone(RemapVote_display);
174                                                 votecalled = TRUE;
175                                                 votecalledmaster = FALSE;
176                                                 votefinished = time + cvar("sv_vote_timeout");
177                                                 votecaller = e; // remember who called the vote
178                                                 if(e) {
179                                                         e.vote_vote = 1; // of course you vote yes
180                                                         e.vote_next = time + cvar("sv_vote_wait");
181                                                 }
182                                                 bprint("\{1}^2* ^3", VoteNetname(votecaller), "^2 calls a vote for ", votecalledvote_display, "\n");
183                                                 if(cvar("sv_eventlog"))
184                                                         GameLogEcho(strcat(":vote:vcall:", ftos(votecaller.playerid), ":", votecalledvote_display));
185                                                 VoteCount(); // needed if you are the only one
186                                                 Nagger_VoteChanged();
187                                         } else {
188                                                 print_to(e, "^1This vote is not ok. See help for more info.");
189                                         }
190                                 }
191                         } else {
192                                 print_to(e, "^1Vote calling is NOT allowed.");
193                         }
194                 } else if(argv(1) == "stop") {
195                         if(!votecalled) {
196                                 print_to(e, "^1No vote called.");
197                         } else if(e == votecaller) { // the votecaller can stop a vote
198                                 VoteStop(e);
199                         } else if(!e) { // server admin / console can too
200                                 VoteStop(e);
201                         } else if(e.vote_master) { // masters can too
202                                 VoteStop(e);
203                         } else {
204                                 print_to(e, "^1You are not allowed to stop that Vote.");
205                         }
206                 } else if(argv(1) == "master") {
207                         if(cvar("sv_vote_master")) {
208                                 if(votecalled) {
209                                         print_to(e, "^1There is already a vote called.");
210                                 } else {
211                                         votecalled = TRUE;
212                                         votecalledmaster = TRUE;
213                                         votecalledvote = strzone("XXX");
214                                         votecalledvote_display = strzone("^3master");
215                                         votefinished = time + cvar("sv_vote_timeout");
216                                         votecaller = e; // remember who called the vote
217                                         if(e) {
218                                                 e.vote_vote = 1; // of course you vote yes
219                                                 e.vote_next = time + cvar("sv_vote_wait");
220                                         }
221                                         bprint("\{1}^2* ^3", VoteNetname(votecaller), "^2 calls a vote to become ^3master^2.\n");
222                                         if(cvar("sv_eventlog"))
223                                                 GameLogEcho(strcat(":vote:vcall:", ftos(votecaller.playerid), ":", votecalledvote_display));
224                                         VoteCount(); // needed if you are the only one
225                                         Nagger_VoteChanged();
226                                 }
227                         } else {
228                                 print_to(e, "^1Vote to become master is NOT allowed.");
229                         }
230                 } else if(argv(1) == "do") {
231                         if(!e || e.vote_master) {
232                                 local string dovote;
233                                 dovote = VoteParse(s, argc);
234                                 if(dovote == "") {
235                                         print_to(e, "^1Your command was empty. See help for more info.");
236                                 } else if(VoteCheckNasty(dovote)) {
237                                         print_to(e, "Syntax error in command. See help for more info.");
238                                 } else if(RemapVote(dovote, "vdo", e)) { // strcat seems to be necessary
239                                         bprint("\{1}^2* ^3", VoteNetname(e), "^2 used his ^3master^2 status to do \"^2", RemapVote_display, "^2\".\n");
240                                         if(cvar("sv_eventlog"))
241                                                 GameLogEcho(strcat(":vote:vdo:", ftos(e.playerid), ":", RemapVote_display));
242                                         localcmd(strcat(RemapVote_vote, "\n"));
243                                 } else {
244                                         print_to(e, "^1This command is not ok. See help for more info.");
245                                 }
246                         } else {
247                                 print_to(e, "^1You are NOT a master.  You might need to login or vote to become master first. See help for more info.");
248                         }
249                 } else if(argv(1) == "login") {
250                         local string masterpwd;
251                         masterpwd = cvar_string("sv_vote_master_password");
252                         if(masterpwd != "") {
253                                 local float granted;
254                                 granted = (masterpwd == argv(2));
255                                 if (e)
256                                         e.vote_master = granted;
257                                 if(granted) {
258                                         print("Accepted master login from ", VoteNetname(e), "\n");
259                                         bprint("\{1}^2* ^3", VoteNetname(e), "^2 logged in as ^3master^2\n");
260                                         if(cvar("sv_eventlog"))
261                                                 GameLogEcho(strcat(":vote:vlogin:", ftos(e.playerid)));
262                                 }
263                                 else
264                                         print("REJECTED master login from ", VoteNetname(e), "\n");
265                         }
266                         else
267                                 print_to(e, "^1Login to become master is NOT allowed.");
268                 } else if(argv(1) == "yes") {
269                         if(!votecalled) {
270                                 print_to(e, "^1No vote called.");
271                         } else if (!e) {
272                                 print_to(e, "^1You can't vote from the server console.");
273                         } else if(e.vote_vote == 0
274                                   || cvar("sv_vote_change")) {
275                                 print_to(e, "^1You accepted the vote.");
276                                 e.vote_vote = 1;
277                                 centerprint_expire(e, CENTERPRIO_VOTE);
278                                 if(!cvar("sv_vote_singlecount")) {
279                                         VoteCount();
280                                 }
281                         } else {
282                                 print_to(e, "^1You have already voted.");
283                         }
284                 } else if(argv(1) == "no") {
285                         if(!votecalled) {
286                                 print_to(e, "^1No vote called.");
287                         } else if (!e) {
288                                 print_to(e, "^1You can't vote from the server console.");
289                         } else if(e.vote_vote == 0
290                                   || cvar("sv_vote_change")) {
291                                 print_to(e, "^1You rejected the vote.");
292                                 e.vote_vote = -1;
293                                 centerprint_expire(e, CENTERPRIO_VOTE);
294                                 if(!cvar("sv_vote_singlecount")) {
295                                         VoteCount();
296                                 }
297                         } else {
298                                 print_to(e, "^1You have already voted.");
299                         }
300                 } else if(argv(1) == "abstain" || argv(1) == "dontcare") {
301                         if(!votecalled) {
302                                 print_to(e, "^1No vote called.");
303                         } else if (!e) {
304                                 print_to(e, "^1You can't vote from the server console.");
305                         } else if(e.vote_vote == 0
306                                   || cvar("sv_vote_change")) {
307                                 print_to(e, "^1You abstained from your vote.");
308                                 e.vote_vote = -2;
309                                 centerprint_expire(e, CENTERPRIO_VOTE);
310                                 if(!cvar("sv_vote_singlecount")) {
311                                         VoteCount();
312                                 }
313                         } else {
314                                 print_to(e, "^1You have already voted.");
315                         }
316                 } else {
317                         // ignore this?
318                         print_to(e, "^1Unknown vote command.");
319                 }
320                 return TRUE;
321         }
322         return FALSE;
323 }
324
325 void VoteHelp(entity e) {
326         local string vmasterdis;
327         if(!cvar("sv_vote_master")) {
328                 vmasterdis = " ^1(disabled)";
329         }
330
331         local string vlogindis;
332         if("" == cvar_string("sv_vote_master_password")) {
333                 vlogindis = " ^1(disabled)";
334         }
335
336         local string vcalldis;
337         if(!cvar("sv_vote_call")) {
338                 vcalldis = " ^1(disabled)";
339         }
340
341         print_to(e, "^7You can use voting with \"^2cmd vote help^7\" \"^2cmd vote status^7\" \"^2cmd vote call ^3COMMAND ARGUMENTS^7\" \"^2cmd vote stop^7\" \"^2cmd vote master^7\" \"^2cmd vote login^7\" \"^2cmd vote do ^3COMMAND ARGUMENTS^7\" \"^2cmd vote yes^7\" \"^2cmd vote no^7\" \"^2cmd vote abstain^7\" \"^2cmd vote dontcare^7\".");
342         print_to(e, "^7Or if your version is up to date you can use these aliases \"^2vhelp^7\" \"^2vstatus^7\" \"^2vcall ^3COMMAND ARGUMENTS^7\" \"^2vstop^7\" \"^2vmaster^7\" \"^2vlogin^7\" \"^2vdo ^3COMMAND ARGUMENTS^7\" \"^2vyes^7\" \"^2vno^7\" \"^2abstain^7\" \"^2vdontcare^7\".");
343         print_to(e, "^7\"^2help^7\" shows this info.");
344         print_to(e, "^7\"^2status^7\" shows if there is a vote called and who called it.");
345         print_to(e, strcat("^7\"^2call^7\" is used to call a vote. See the list of allowed commands.", vcalldis, "^7"));
346         print_to(e, "^7\"^2stop^7\" can be used by the vote caller or an admin to stop a vote and maybe correct it.");
347         print_to(e, strcat("^7\"^2master^7\" call a vote to become master who can execute commands without a vote", vmasterdis, "^7"));
348         print_to(e, strcat("^7\"^2login^7\" login to become master who can execute commands without a vote.", vlogindis, "^7"));
349         print_to(e, "^7\"^2do^7\" executes a command if you are a master. See the list of allowed commands.");
350         print_to(e, "^7\"^2yes^7\", \"^2no^7\", \"^2abstain^7\" and \"^2dontcare^7\" to make your vote.");
351         print_to(e, "^7If enough of the players vote yes the vote is accepted.");
352         print_to(e, "^7If enough of the players vote no the vote is rejected.");
353         print_to(e, strcat("^7If neither the vote will timeout after ", cvar_string("sv_vote_timeout"), "^7 seconds."));
354         print_to(e, "^7You can call a vote for or execute these commands:");
355         print_to(e, strcat("^3", cvar_string("sv_vote_commands"), "^7 and maybe further ^3arguments^7"));
356 }
357
358 string VoteNetname(entity e)
359 {
360         if(e) {
361                 return e.netname;
362         } else {
363                 if(cvar_string("sv_adminnick") != "") {
364                         return cvar_string("sv_adminnick");
365                 } else {
366                         return cvar_string("hostname");
367                 }
368         }
369 }
370
371 string ValidateMap(string m, entity e)
372 {
373         m = MapInfo_FixName(m);
374         if(!m)
375         {
376                 print_to(e, "This map is not available on this server.");
377                 return string_null;
378         }
379         if(!cvar("sv_vote_override_mostrecent"))
380                 if(Map_IsRecent(m))
381                 {
382                         print_to(e, "This server does not allow for recent maps to be played again. Please be patient for some rounds.");
383                         return string_null;
384                 }
385         if(!MapInfo_CheckMap(m))
386         {
387                 print_to(e, strcat("^1Invalid mapname, \"^3", m, "^1\" does not support the current game mode."));
388                 return string_null;
389         }
390
391         return m;
392 }
393
394
395 void VoteThink() {
396         if(votefinished > 0) // a vote was called
397         if(time > votefinished) // time is up
398         {
399                 VoteCount();
400         }
401 }
402
403 string VoteParse(string all, float argc) {
404         if(argc < 3)
405                 return "";
406         return substring(all, argv_start_index(2), argv_end_index(-1) - argv_start_index(2));
407 }
408
409 float VoteAllowed(string votecommand, string cmd) {
410         local float index;
411
412         tokenize_sane(cvar_string("sv_vote_commands"));
413         index = 0;
414         while(argv(index) != "") {
415                 if(votecommand == argv(index)) {
416                         return TRUE;
417                 }
418                 ++index;
419         }
420
421         if(cmd == "vdo")
422                 tokenize_sane(cvar_string("sv_vote_master_commands"));
423         else
424                 tokenize_sane(cvar_string("sv_vote_only_commands"));
425         index = 0;
426         while(argv(index) != "") {
427                 if(votecommand == argv(index)) {
428                         return TRUE;
429                 }
430                 ++index;
431         }
432
433         return FALSE;
434 }
435
436 void VoteReset() {
437         local entity player;
438
439         FOR_EACH_CLIENT(player)
440         {
441                 player.vote_vote = 0;
442                 centerprint_expire(player, CENTERPRIO_VOTE);
443         }
444
445         if(votecalled)
446         {
447                 strunzone(votecalledvote);
448                 strunzone(votecalledvote_display);
449         }
450
451         votecalled = FALSE;
452         votecalledmaster = FALSE;
453         votefinished = 0;
454         Nagger_VoteChanged();
455 }
456
457 void VoteAccept() {
458         bprint("\{1}^2* ^3", VoteNetname(votecaller), "^2's vote for ^1", votecalledvote_display, "^2 was accepted\n");
459         if(votecalledmaster)
460         {
461                 if(votecaller) {
462                         votecaller.vote_master = 1;
463                 }
464         } else {
465                 localcmd(strcat(votecalledvote, "\n"));
466         }
467         if(votecaller) {
468                 votecaller.vote_next = 0; // people like your votes,
469                                           // no wait for next vote
470         }
471         VoteReset();
472 }
473
474 void VoteReject() {
475         bprint("\{1}^2* ^3", VoteNetname(votecaller), "^2's vote for ", votecalledvote_display, "^2 was rejected\n");
476         VoteReset();
477 }
478
479 void VoteTimeout() {
480         bprint("\{1}^2* ^3", VoteNetname(votecaller), "^2's vote for ", votecalledvote_display, "^2 timed out\n");
481         VoteReset();
482 }
483
484 void VoteStop(entity stopper) {
485         bprint("\{1}^2* ^3", VoteNetname(stopper), "^2 stopped ^3", VoteNetname(votecaller), "^2's vote\n");
486         if(cvar("sv_eventlog"))
487                 GameLogEcho(strcat(":vote:vstop:", ftos(stopper.playerid)));
488         if(stopper == votecaller) {
489                 // no wait for next vote so you can correct your vote
490                 if(votecaller) {
491                         votecaller.vote_next = 0;
492                 }
493         }
494         VoteReset();
495 }
496
497 void VoteSpam(float yescount, float nocount, float abstaincount, float notvoters, float mincount, string result)
498 {
499         string s;
500         if(mincount >= 0)
501         {
502                 s = strcat("\{1}^2* vote results: ^1", ftos(yescount), "^2:^1");
503                 s = strcat(s, ftos(nocount), "^2 (^1");
504                 s = strcat(s, ftos(mincount), "^2 needed), ^1");
505                 s = strcat(s, ftos(abstaincount), "^2 didn't care, ^1");
506                 s = strcat(s, ftos(notvoters), "^2 didn't vote\n");
507         }
508         else
509         {
510                 s = strcat("\{1}^2* vote results: ^1", ftos(yescount), "^2:^1");
511                 s = strcat(s, ftos(nocount), "^2, ^1");
512                 s = strcat(s, ftos(abstaincount), "^2 didn't care, ^1");
513                 s = strcat(s, ftos(notvoters), "^2 didn't have to vote\n");
514         }
515         bprint(s);
516         if(cvar("sv_eventlog"))
517         {
518                 s = strcat(":vote:v", result, ":", ftos(yescount));
519                 s = strcat(s, ":", ftos(nocount));
520                 s = strcat(s, ":", ftos(abstaincount));
521                 s = strcat(s, ":", ftos(notvoters));
522                 s = strcat(s, ":", ftos(mincount));
523                 GameLogEcho(s);
524         }
525 }
526
527 void VoteCount() {
528         local float playercount;
529         playercount = 0;
530         local float yescount;
531         yescount = 0;
532         local float nocount;
533         nocount = 0;
534         local float abstaincount;
535         abstaincount = 0;
536         local entity player;
537         //same for real players
538         local float realplayercount;
539         local float realplayeryescount;
540         local float realplayernocount;
541         local float realplayerabstaincount;
542         realplayercount = realplayernocount = realplayerabstaincount = realplayeryescount = 0;
543
544         FOR_EACH_REALCLIENT(player)
545         {
546                 if(player.vote_vote == -1) {
547                         ++nocount;
548                 } else if(player.vote_vote == 1) {
549                         ++yescount;
550                 } else if(player.vote_vote == -2) {
551                         ++abstaincount;
552                 }
553                 ++playercount;
554                 //do the same for real players
555                 if(player.classname == "player") {
556                         if(player.vote_vote == -1) {
557                                 ++realplayernocount;
558                         } else if(player.vote_vote == 1) {
559                                 ++realplayeryescount;
560                         } else if(player.vote_vote == -2) {
561                                 ++realplayerabstaincount;
562                         }
563                         ++realplayercount;
564                 }
565         }
566
567         //in tournament mode, if we have at least one player then don't make the vote dependent on spectators (so specs don't have to press F1)
568         if(cvar("sv_vote_nospectators"))
569         if(realplayercount > 0) {
570                 yescount = realplayeryescount;
571                 nocount = realplayernocount;
572                 abstaincount = realplayerabstaincount;
573                 playercount = realplayercount;
574         }
575
576
577         if(votecalledmaster
578            && playercount == 1) {
579                 // if only one player is on the server becoming vote
580                 // master is not allowed.  This could be used for
581                 // trolling or worse. 'self' is the user who has
582                 // called the vote because this function is called
583                 // by SV_ParseClientCommand. Maybe all voting should
584                 // be disabled for a single player?
585                 print_to(votecaller, "^1You are the only player on this server so you can not become vote master.");
586                 if(votecaller) {
587                         votecaller.vote_next = 0;
588                 }
589                 VoteReset();
590         } else {
591                 float votefactor, simplevotefactor;
592                 votefactor = bound(0.5, cvar("sv_vote_majority_factor"), 0.999);
593                 simplevotefactor = cvar("sv_vote_simple_majority_factor");
594                 if(yescount > (playercount - abstaincount) * votefactor)
595                 {
596                         VoteSpam(yescount, nocount, abstaincount, playercount - yescount - nocount - abstaincount, -1, "yes");
597                         VoteAccept();
598                 }
599                 else if(nocount >= (playercount - abstaincount) * (1 - votefactor)) // that means, yescount cannot reach minyes any more
600                 {
601                         VoteSpam(yescount, nocount, abstaincount, playercount - yescount - nocount - abstaincount, -1, "no");
602                         VoteReject();
603                 }
604                 else if(time > votefinished)
605                 {
606                         if(simplevotefactor)
607                         {
608                                 string result;
609                                 simplevotefactor = bound(votefactor, simplevotefactor, 0.999);
610                                 if(yescount > (yescount + nocount) * simplevotefactor)
611                                         result = "yes";
612                                 else if(yescount + nocount > 0)
613                                         result = "no";
614                                 else
615                                         result = "timeout";
616                                 VoteSpam(yescount, nocount, abstaincount, playercount - yescount - nocount - abstaincount, floor((yescount + nocount) * votefactor) + 1, result);
617                                 if(result == "yes")
618                                         VoteAccept();
619                                 else if(result == "no")
620                                         VoteReject();
621                                 else
622                                         VoteTimeout();
623                         }
624                         else
625                         {
626                                 VoteSpam(yescount, nocount, abstaincount, playercount - yescount - nocount - abstaincount, floor((playercount - abstaincount) * votefactor) + 1, "timeout");
627                                 VoteTimeout();
628                         }
629                 }
630         }
631
632         Nagger_VoteCountChanged();
633 }