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