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