float mapvote_maps_suggested[MAPVOTE_COUNT];
string mapvote_suggestions[MAPVOTE_COUNT];
float mapvote_suggestion_ptr;
-float mapvote_voters;
-float mapvote_votes[MAPVOTE_COUNT];
+float mapvote_selectionrs;
+float mapvote_selections[MAPVOTE_COUNT];
float mapvote_run;
float mapvote_detail;
float mapvote_abstain;
if(mapvote_detail)
for(i = 0; i < mapvote_count; ++i)
if(mapvote_maps[i] != "")
- WriteByte(MSG_ENTITY, mapvote_votes[i]);
+ WriteByte(MSG_ENTITY, mapvote_selections[i]);
WriteByte(MSG_ENTITY, to.mapvote);
}
if(autocvar_sv_eventlog)
{
result = strcat(":vote:finished:", mapvote_maps[mappos]);
- result = strcat(result, ":", ftos(mapvote_votes[mappos]), "::");
- didntvote = mapvote_voters;
+ result = strcat(result, ":", ftos(mapvote_selections[mappos]), "::");
+ didntvote = mapvote_selectionrs;
for(i = 0; i < mapvote_count; ++i)
if(mapvote_maps[i] != "")
{
- didntvote -= mapvote_votes[i];
+ didntvote -= mapvote_selections[i];
if(i != mappos)
{
result = strcat(result, ":", mapvote_maps[i]);
- result = strcat(result, ":", ftos(mapvote_votes[i]));
+ result = strcat(result, ":", ftos(mapvote_selections[i]));
}
}
result = strcat(result, ":didn't vote:", ftos(didntvote));
for(i = 0; i < mapvote_count; ++i) if(mapvote_maps[i] != "")
{
//dprint("Map ", ftos(i), ": "); dprint(mapvote_maps[i], "\n");
- mapvote_votes[i] = 0;
+ mapvote_selections[i] = 0;
}
- mapvote_voters = 0;
+ mapvote_selectionrs = 0;
FOR_EACH_REALCLIENT(other)
{
- ++mapvote_voters;
+ ++mapvote_selectionrs;
if(other.mapvote)
{
i = other.mapvote - 1;
//dprint("Player ", other.netname, " vote = ", ftos(other.mapvote - 1), "\n");
- mapvote_votes[i] = mapvote_votes[i] + 1;
+ mapvote_selections[i] = mapvote_selections[i] + 1;
}
}
}
float i;
float firstPlace, secondPlace;
float firstPlaceVotes, secondPlaceVotes;
- float mapvote_voters_real;
+ float mapvote_selectionrs_real;
string result;
if(mapvote_count_real == 1)
return MapVote_Finished(0);
- mapvote_voters_real = mapvote_voters;
+ mapvote_selectionrs_real = mapvote_selectionrs;
if(mapvote_abstain)
- mapvote_voters_real -= mapvote_votes[mapvote_count - 1];
+ mapvote_selectionrs_real -= mapvote_selections[mapvote_count - 1];
RandomSelection_Init();
for(i = 0; i < mapvote_count_real; ++i) if(mapvote_maps[i] != "")
- RandomSelection_Add(world, i, string_null, 1, mapvote_votes[i]);
+ RandomSelection_Add(world, i, string_null, 1, mapvote_selections[i]);
firstPlace = RandomSelection_chosen_float;
firstPlaceVotes = RandomSelection_best_priority;
//dprint("First place: ", ftos(firstPlace), "\n");
RandomSelection_Init();
for(i = 0; i < mapvote_count_real; ++i) if(mapvote_maps[i] != "")
if(i != firstPlace)
- RandomSelection_Add(world, i, string_null, 1, mapvote_votes[i]);
+ RandomSelection_Add(world, i, string_null, 1, mapvote_selections[i]);
secondPlace = RandomSelection_chosen_float;
secondPlaceVotes = RandomSelection_best_priority;
//dprint("Second place: ", ftos(secondPlace), "\n");
if(firstPlace == -1)
error("No first place in map vote... WTF?");
- if(secondPlace == -1 || time > mapvote_timeout || (mapvote_voters_real - firstPlaceVotes) < firstPlaceVotes)
+ if(secondPlace == -1 || time > mapvote_timeout || (mapvote_selectionrs_real - firstPlaceVotes) < firstPlaceVotes)
return MapVote_Finished(firstPlace);
if(mapvote_keeptwotime)
- if(time > mapvote_keeptwotime || (mapvote_voters_real - firstPlaceVotes - secondPlaceVotes) < secondPlaceVotes)
+ if(time > mapvote_keeptwotime || (mapvote_selectionrs_real - firstPlaceVotes - secondPlaceVotes) < secondPlaceVotes)
{
float didntvote;
MapVote_TouchMask();
result = strcat(result, ":", ftos(firstPlaceVotes));
result = strcat(result, ":", mapvote_maps[secondPlace]);
result = strcat(result, ":", ftos(secondPlaceVotes), "::");
- didntvote = mapvote_voters;
+ didntvote = mapvote_selectionrs;
for(i = 0; i < mapvote_count; ++i)
if(mapvote_maps[i] != "")
{
- didntvote -= mapvote_votes[i];
+ didntvote -= mapvote_selections[i];
if(i != firstPlace)
if(i != secondPlace)
{
result = strcat(result, ":", mapvote_maps[i]);
- result = strcat(result, ":", ftos(mapvote_votes[i]));
+ result = strcat(result, ":", ftos(mapvote_selections[i]));
if(i < mapvote_count_real)
{
strunzone(mapvote_maps[i]);
#define VC_ASGNMNT_CLIENTONLY 2
#define VC_ASGNMNT_SERVERONLY 3
+#define VOTE_SELECT_ABSTAIN -2
+#define VOTE_SELECT_REJECT -1
+#define VOTE_SELECT_NULL 0
+#define VOTE_SELECT_ACCEPT 1
// ============================
// Misc. Supporting Functions
|| ((!from_server && assignment == VC_ASGNMNT_CLIENTONLY)
|| (from_server && assignment == VC_ASGNMNT_SERVERONLY)))
{
- print("check_assignment returned true\n");
return TRUE;
}
-
- print("check_assignment returned false\n");
+
return FALSE;
}
if(votecalled)
{
nags |= 4;
- if(to.vote_vote == 0)
+ if(to.vote_selection == 0)
nags |= 8;
}
if(inWarmupStage)
WriteByte(MSG_ENTITY, vote_yescount);
WriteByte(MSG_ENTITY, vote_nocount);
WriteByte(MSG_ENTITY, vote_needed_absolute);
- WriteChar(MSG_ENTITY, to.vote_vote);
+ WriteChar(MSG_ENTITY, to.vote_selection);
}
if(nags & 128)
*/
void ReadyCount()
{
- local entity e;
- local float r, p;
+ entity tmp_player;
+ float t_ready, t_players;
- r = p = 0;
-
- FOR_EACH_REALPLAYER(e)
+ FOR_EACH_REALPLAYER(tmp_player)
{
- p += 1;
- if(e.ready)
- r += 1;
+ ++t_players;
+ if(tmp_player.ready) { ++t_ready; }
}
- readycount = r;
+ readycount = t_ready;
Nagger_ReadyCounted();
- if(r) // at least one is ready
- if(r == p) // and, everyone is ready
+ // TODO: Add ability to
+ if(t_ready) // at least one is ready
+ if(t_ready == t_players) // and, everyone is ready
ReadyRestart();
}
-/**
- * Restarts the map after the countdown is over (and cvar sv_ready_restart_after_countdown
- * is set)
- */
-void restartTimer_Think() {
+
+// Restarts the map after the countdown is over (and cvar sv_ready_restart_after_countdown is set)
+void restartTimer_Think()
+{
restart_mapalreadyrestarted = 1;
reset_map(TRUE);
Score_ClearAll();
return TRUE;
if(strstrofs(cmd, "$", 0) >= 0)
return TRUE;
+
return FALSE;
}
}
string RemapVote_display;
-string RemapVote_vote;
+string Remapvote_selection;
float RemapVote(string vote, string cmd, entity e)
{
float vote_argc;
{
if(!(victim = GetKickVoteVictim(vote, cmd, e)))
return FALSE;
- RemapVote_vote = GetKickVoteVictim_newcommand;
+ Remapvote_selection = GetKickVoteVictim_newcommand;
RemapVote_display = strcat("^1", vote, " (^7", victim.netname, "^1): ", GetKickVoteVictim_reason);
}
else
{
- RemapVote_vote = vote;
+ Remapvote_selection = vote;
RemapVote_display = strzone(strcat("^1", vote));
}
// =======================
void VoteCommand_abstain(float request, entity caller)
+{
+ switch(request)
+ {
+ case VC_REQUEST_COMMAND:
+ {
+ if(votecalled)
+ {
+ if(caller.vote_selection == VOTE_SELECT_NULL || autocvar_sv_vote_change)
+ {
+ print_to(caller, "^1You abstained from your vote.");
+ caller.vote_selection = VOTE_SELECT_ABSTAIN;
+ msg_entity = caller;
+ if(!autocvar_sv_vote_singlecount) { VoteCount(); }
+ }
+ else { print_to(caller, "^1You have already voted."); }
+ }
+ else { print_to(caller, "^1No vote called."); }
+
+ return;
+ }
+
+ default:
+ case VC_REQUEST_USAGE:
+ {
+ print("\nUsage:^3 vote abstain\n");
+ print(" No arguments required.\n");
+ return;
+ }
+ }
+}
+
+void VoteCommand_call(float request, entity caller, float argc)
+{
+ switch(request)
+ {
+ case VC_REQUEST_COMMAND:
+ {
+
+ return;
+ }
+
+ default:
+ case VC_REQUEST_USAGE:
+ {
+ print("\nUsage:^3 vote call\n");
+ print(" No arguments required.\n");
+ return;
+ }
+ }
+}
+
+void VoteCommand_force(float request, float argc)
{
switch(request)
{
}
}
+void VoteCommand_master(float request, entity caller, float argc)
+{
+ switch(request)
+ {
+ case VC_REQUEST_COMMAND:
+ {
+
+ return;
+ }
+
+ default:
+ case VC_REQUEST_USAGE:
+ {
+ print("\nUsage:^3 vote master action [arguments]\n");
+ print(" No arguments required.\n");
+ return;
+ }
+ }
+}
+
+void VoteCommand_no(float request, entity caller)
+{
+ switch(request)
+ {
+ case VC_REQUEST_COMMAND:
+ {
+ if(votecalled)
+ {
+ if(caller.vote_selection == VOTE_SELECT_NULL || autocvar_sv_vote_change)
+ {
+ print_to(caller, "^1You rejected the vote.");
+ caller.vote_selection = VOTE_SELECT_REJECT;
+ msg_entity = caller;
+ if(!autocvar_sv_vote_singlecount) { VoteCount(); }
+ }
+ else { print_to(caller, "^1You have already voted."); }
+ }
+ else { print_to(caller, "^1No vote called."); }
+
+ return;
+ }
+
+ default:
+ case VC_REQUEST_USAGE:
+ {
+ print("\nUsage:^3 vote no\n");
+ print(" No arguments required.\n");
+ return;
+ }
+ }
+}
+
+void VoteCommand_status(float request, entity caller)
+{
+ switch(request)
+ {
+ case VC_REQUEST_COMMAND:
+ {
+
+ return;
+ }
+
+ default:
+ case VC_REQUEST_USAGE:
+ {
+ print("\nUsage:^3 vote status\n");
+ print(" No arguments required.\n");
+ return;
+ }
+ }
+}
+
void VoteCommand_stop(float request, entity caller)
{
switch(request)
default:
case VC_REQUEST_USAGE:
{
- print("\nUsage:^3 vote \n");
+ print("\nUsage:^3 vote stop\n");
+ print(" No arguments required.\n");
+ return;
+ }
+ }
+}
+
+void VoteCommand_yes(float request, entity caller)
+{
+ switch(request)
+ {
+ case VC_REQUEST_COMMAND:
+ {
+ if(votecalled)
+ {
+ if(caller.vote_selection == VOTE_SELECT_NULL || autocvar_sv_vote_change)
+ {
+ print_to(caller, "^1You accepted the vote.");
+ caller.vote_selection = VOTE_SELECT_ACCEPT;
+ msg_entity = caller;
+ if(!autocvar_sv_vote_singlecount) { VoteCount(); }
+ }
+ else { print_to(caller, "^1You have already voted."); }
+ }
+ else { print_to(caller, "^1No vote called."); }
+
+ return;
+ }
+
+ default:
+ case VC_REQUEST_USAGE:
+ {
+ print("\nUsage:^3 vote yes\n");
print(" No arguments required.\n");
return;
}
*/
-// ==================================
-// Macro system for server commands
-// ==================================
+// ================================
+// Macro system for vote commands
+// ================================
// Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
#define VOTE_COMMANDS(request,caller,arguments) \
VOTE_COMMAND("abstain", VoteCommand_abstain(request, caller), "Abstain your vote in current vote", VC_ASGNMNT_CLIENTONLY) \
VOTE_COMMAND("call", VoteCommand_call(request, caller, arguments), "Create a new vote for players to decide on", VC_ASGNMNT_BOTH) \
- VOTE_COMMAND("force", VoteCommand_force(request, caller), "Force a result of a vote", VC_ASGNMNT_SERVERONLY) \
- VOTE_COMMAND("help", VoteCommand_macro_help(caller), "Shows this information", VC_ASGNMNT_BOTH) \
+ VOTE_COMMAND("force", VoteCommand_force(request, arguments), "Force the result of a vote", VC_ASGNMNT_SERVERONLY) \
+ VOTE_COMMAND("help", VoteCommand_macro_help(caller, arguments), "Shows this information", VC_ASGNMNT_BOTH) \
VOTE_COMMAND("master", VoteCommand_master(request, caller, arguments), "", VC_ASGNMNT_CLIENTONLY) \
- VOTE_COMMAND("no", VoteCommand_no(request, caller), "Vote no in current poll", VC_ASGNMNT_CLIENTONLY) \
- VOTE_COMMAND("status", VoteCommand_status(request, caller), "Prints information about current poll", VC_ASGNMNT_BOTH) \
+ VOTE_COMMAND("no", VoteCommand_no(request, caller), "Select no in current vote", VC_ASGNMNT_CLIENTONLY) \
+ VOTE_COMMAND("status", VoteCommand_status(request, caller), "Prints information about current vote", VC_ASGNMNT_BOTH) \
VOTE_COMMAND("stop", VoteCommand_stop(request, caller), "Immediately end a vote", VC_ASGNMNT_BOTH) \
- VOTE_COMMAND("yes", VoteCommand_yes(request, caller), "Vote yes in current poll", VC_ASGNMNT_CLIENTONLY) \
+ VOTE_COMMAND("yes", VoteCommand_yes(request, caller), "Select yes in current vote", VC_ASGNMNT_CLIENTONLY) \
/* nothing */
-void VoteCommand_macro_help(entity caller)
+void VoteCommand_macro_help(entity caller, float argc)
{
- print("\nUsage:^3 ", VoteCommand_getprefix(caller), " vote COMMAND...^7, where possible commands are:\n");
+ string command_origin = VoteCommand_getprefix(caller);
- #define VOTE_COMMAND(name,function,description,assignment) \
- { if(Votecommand_check_assignment(caller, assignment)) { print(" ^2", name, "^7: ", description, "\n"); } }
+ if(argc == 2) // help display listing all commands
+ {
+ print("\nUsage:^3 ", command_origin, " vote COMMAND...^7, where possible commands are:\n");
- VOTE_COMMANDS(0, caller, 0)
- #undef VOTE_COMMAND
+ #define VOTE_COMMAND(name,function,description,assignment) \
+ { if(Votecommand_check_assignment(caller, assignment)) { print(" ^2", name, "^7: ", description, "\n"); } }
+
+ VOTE_COMMANDS(0, caller, 0)
+ #undef VOTE_COMMAND
+
+ print("For help about specific commands, type ", command_origin, " vote help COMMAND\n");
+ }
+ else // usage for individual command
+ {
+ #define VOTE_COMMAND(name,function,description,assignment) \
+ { if(Votecommand_check_assignment(caller, assignment)) { if(name == strtolower(argv(2))) { function; return; } } }
+
+ VOTE_COMMANDS(VC_REQUEST_USAGE, caller, argc)
+ #undef VOTE_COMMAND
+ }
return;
}
float VoteCommand_macro_command(entity caller, float argc)
-{
- #define VOTE_COMMAND(name,function,description,assignment) \
- { if(Votecommand_check_assignment(caller, assignment)) { if(name == strtolower(argv(0))) { function; return TRUE; } } }
-
- VOTE_COMMANDS(VC_REQUEST_COMMAND, caller, argc)
- #undef VOTE_COMMAND
-
- return FALSE;
-}
-
-float VoteCommand_macro_usage(entity caller, float argc)
{
#define VOTE_COMMAND(name,function,description,assignment) \
{ if(Votecommand_check_assignment(caller, assignment)) { if(name == strtolower(argv(1))) { function; return TRUE; } } }
- VOTE_COMMANDS(VC_REQUEST_USAGE, caller, argc)
+ VOTE_COMMANDS(VC_REQUEST_COMMAND, caller, argc)
#undef VOTE_COMMAND
return FALSE;
// Main function handling vote commands
// ======================================
-void VoteCommand(entity caller, float argc)
+void VoteCommand(float request, entity caller, float argc)
{
- if(strtolower(argv(0)) == "help")
+ switch(request)
{
- if(argc == 1)
+ case VC_REQUEST_COMMAND:
{
- VoteCommand_macro_help(caller);
- return;
+ if(VoteCommand_macro_command(caller, argc))
+ return;
}
- else if(VoteCommand_macro_usage(caller, argc))
+
+ default:
+ print_to(caller, strcat("Unknown vote command", ((argv(1) != "") ? strcat(" \"", argv(1), "\"") : ""), ". For a list of supported commands, try ", VoteCommand_getprefix(caller), " help.\n"));
+ case VC_REQUEST_USAGE:
{
+ VoteCommand_macro_help(caller, argc);
return;
}
}
- else if(VoteCommand_macro_command(caller, argc))
- {
- return;
- }
-
- // nothing above caught the command, must be invalid
- //print("Unknown server command", ((command != "") ? strcat(" \"", command, "\"") : ""), ". For a list of supported commands, try sv_cmd help.\n");
}
void VoteHelp(entity e) {
FOR_EACH_CLIENT(player)
{
- player.vote_vote = 0;
+ player.vote_selection = 0;
}
if(votecalled)
FOR_EACH_REALCLIENT(player)
{
- if(player.vote_vote == -1) {
+ if(player.vote_selection == -1) {
++vote_nocount;
- } else if(player.vote_vote == 1) {
+ } else if(player.vote_selection == 1) {
++vote_yescount;
- } else if(player.vote_vote == -2) {
+ } else if(player.vote_selection == -2) {
++vote_abstaincount;
}
++playercount;
//do the same for real players
if(player.classname == "player") {
- if(player.vote_vote == -1) {
+ if(player.vote_selection == -1) {
++realplayernocount;
- } else if(player.vote_vote == 1) {
+ } else if(player.vote_selection == 1) {
++realplayeryescount;
- } else if(player.vote_vote == -2) {
+ } else if(player.vote_selection == -2) {
++realplayerabstaincount;
}
++realplayercount;