From 073cb3d53143f8ed0d66ac0d4365db0b9b3d069c Mon Sep 17 00:00:00 2001 From: div0 Date: Sat, 5 Jan 2008 09:38:00 +0000 Subject: [PATCH] g_maplist_votable_abstain 1, and people can abstain from their map vote git-svn-id: svn://svn.icculus.org/nexuiz/trunk@3104 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/default.cfg | 1 + data/qcsrc/server/g_world.qc | 44 ++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/data/default.cfg b/data/default.cfg index e94cc1e42..1bba11242 100644 --- a/data/default.cfg +++ b/data/default.cfg @@ -711,6 +711,7 @@ seta g_maplist_votable_suggestions 2 seta g_maplist_votable_suggestions_change_gametype 0 seta g_maplist_votable_suggestions_override_mostrecent 0 seta g_maplist_votable_nodetail 0 // nodetail only shows total count instead of all vote counts per map, so votes don't influence others that much +seta g_maplist_votable_abstain 0 // when 1, you can abstain from your vote alias suggestmap "cmd suggestmap $1" set g_chat_flood_spl 0 // seconds between lines to not count as flooding diff --git a/data/qcsrc/server/g_world.qc b/data/qcsrc/server/g_world.qc index 48e1af6ed..d7d1cebde 100644 --- a/data/qcsrc/server/g_world.qc +++ b/data/qcsrc/server/g_world.qc @@ -1658,6 +1658,7 @@ string mapvote_message; #define MAPVOTE_COUNT 10 float mapvote_count; +float mapvote_count_real; string mapvote_maps[MAPVOTE_COUNT]; float mapvote_maps_suggested[MAPVOTE_COUNT]; string mapvote_suggestions[MAPVOTE_COUNT]; @@ -1667,6 +1668,7 @@ float mapvote_voters; float mapvote_votes[MAPVOTE_COUNT]; float mapvote_run; float mapvote_detail; +float mapvote_abstain; .float mapvote; void MapVote_ClearAllVotes() @@ -1744,10 +1746,15 @@ void MapVote_Init() MapVote_ClearAllVotes(); - nmax = min(MAPVOTE_COUNT, cvar("g_maplist_votable")); - smax = min(nmax, cvar("g_maplist_votable_suggestions")); mapvote_count = 0; mapvote_detail = !cvar("g_maplist_votable_nodetail"); + mapvote_abstain = cvar("g_maplist_votable_abstain"); + + if(mapvote_abstain) + nmax = min(MAPVOTE_COUNT - 1, cvar("g_maplist_votable")); + else + nmax = min(MAPVOTE_COUNT, cvar("g_maplist_votable")); + smax = min(nmax, cvar("g_maplist_votable_suggestions")); for(i = 0; i < 100 && mapvote_count < smax; ++i) MapVote_AddVotable(mapvote_suggestions[ceil(random() * mapvote_suggestion_ptr) - 1], TRUE); @@ -1768,11 +1775,15 @@ void MapVote_Init() MapVote_AddVotable(GetNextMap(), FALSE); } + mapvote_count_real = mapvote_count; + if(mapvote_abstain) + MapVote_AddVotable("/abstain", 0); + //dprint("mapvote count is ", ftos(mapvote_count), "\n"); mapvote_keeptwotime = time + cvar("g_maplist_votable_keeptwotime"); mapvote_timeout = time + cvar("g_maplist_votable_timeout"); - if(mapvote_count < 3 || mapvote_keeptwotime <= time) + if(mapvote_count_real < 3 || mapvote_keeptwotime <= time) mapvote_keeptwotime = 0; mapvote_message = "Choose a map and press its key!"; } @@ -1783,7 +1794,7 @@ float MapVote_Finished(float mappos) result = strcat(":vote:finished:", mapvote_maps[mappos]); result = strcat(result, ":", ftos(mapvote_votes[mappos]), "::"); - for(i = 0; i < mapvote_count; ++i) + for(i = 0; i < mapvote_count_real; ++i) if(i != mappos) if(mapvote_maps[i] != "") { @@ -1830,10 +1841,15 @@ float MapVote_CheckRules_2() float i; float firstPlace, secondPlace; float firstPlaceVotes, secondPlaceVotes; + float mapvote_voters_real; string result; + mapvote_voters_real = mapvote_voters; + if(mapvote_abstain) + mapvote_voters_real -= mapvote_votes[mapvote_count - 1]; + RandSel_Init(); - for(i = 0; i < mapvote_count; ++i) if(mapvote_maps[i] != "") + for(i = 0; i < mapvote_count_real; ++i) if(mapvote_maps[i] != "") RandSel_Add(mapvote_votes[i], i); firstPlace = randsel_value; firstPlaceVotes = randsel_priority; @@ -1841,7 +1857,7 @@ float MapVote_CheckRules_2() //dprint("First place votes: ", ftos(firstPlaceVotes), "\n"); RandSel_Init(); - for(i = 0; i < mapvote_count; ++i) if(mapvote_maps[i] != "") + for(i = 0; i < mapvote_count_real; ++i) if(mapvote_maps[i] != "") if(i != firstPlace) RandSel_Add(mapvote_votes[i], i); secondPlace = randsel_value; @@ -1852,11 +1868,11 @@ float MapVote_CheckRules_2() if(firstPlace == -1) error("No first place in map vote... WTF?"); - if(secondPlace == -1 || time > mapvote_timeout || (mapvote_voters - firstPlaceVotes) < firstPlaceVotes) + if(secondPlace == -1 || time > mapvote_timeout || (mapvote_voters_real - firstPlaceVotes) < firstPlaceVotes) return MapVote_Finished(firstPlace); if(mapvote_keeptwotime) - if(time > mapvote_keeptwotime || (mapvote_voters - firstPlaceVotes - secondPlaceVotes) < secondPlaceVotes) + if(time > mapvote_keeptwotime || (mapvote_voters_real - firstPlaceVotes - secondPlaceVotes) < secondPlaceVotes) { mapvote_message = "Now decide between the TOP TWO!"; mapvote_keeptwotime = 0; @@ -1864,7 +1880,7 @@ float MapVote_CheckRules_2() result = strcat(result, ":", ftos(firstPlaceVotes)); result = strcat(result, ":", mapvote_maps[secondPlace]); result = strcat(result, ":", ftos(secondPlaceVotes), "::"); - for(i = 0; i < mapvote_count; ++i) + for(i = 0; i < mapvote_count_real; ++i) if(i != firstPlace) if(i != secondPlace) if(mapvote_maps[i] != "") @@ -1906,14 +1922,6 @@ void MapVote_Tick() msg_entity = other; WriteByte(MSG_ONE, SVC_FINALE); WriteString(MSG_ONE, ""); - /* - for(i = 0; i < mapvote_count; ++i) - if(mapvote_maps[i] != "") - { - tmp = mapvote_maps[i]; - sprint(other, strcat("map voting: type ^1impulse ", ftos(i+1), "^7 to vote for ", tmp, "\n")); - } - */ } } @@ -1949,6 +1957,8 @@ void MapVote_Tick() else { tmp = mapvote_maps[i]; + if(tmp == "/abstain") + tmp = "ABSTAIN!"; tmp = strpad(mapvote_maxlen, tmp); tmp = strcat(ftos(math_mod(i + 1, 10)), ": ", tmp); if(mapvote_detail) -- 2.39.2