From df1a0ca8f11d764c5e065abe37a9720eb78120a3 Mon Sep 17 00:00:00 2001 From: GenZmeY Date: Fri, 8 Jan 2021 22:43:09 +0300 Subject: [PATCH] MapVote changes: - feat: "MapVote orgy" can be configured or disabled (KFxMapVote.ini); - fix: Map change at the end of the game in single player mode (#19). --- ServerExtMut/Classes/xVotingHandler.uc | 29 +++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/ServerExtMut/Classes/xVotingHandler.uc b/ServerExtMut/Classes/xVotingHandler.uc index 7a3a462..de2d3ff 100644 --- a/ServerExtMut/Classes/xVotingHandler.uc +++ b/ServerExtMut/Classes/xVotingHandler.uc @@ -6,9 +6,10 @@ struct FGameModeOption var config string GameName,GameShortName,GameClass,Mutators,Options,Prefix; }; var config array GameModes; -var config int LastVotedGameInfo,VoteTime,MaxMapsOnList; +var config int LastVotedGameInfo,VoteTime,MaxMapsOnList,VoteNumForOrgy; var config float MidGameVotePct,MapWinPct,MapChangeDelay; var config bool bNoWebAdmin; +var config bool bNoMapVoteOrgy; var class BaseMutator; @@ -25,6 +26,7 @@ function PostBeginPlay() { local int i,j,z,n,UpV,DownV,Seq,NumPl; local string S,MapFile; + local bool ConfigChanged; if (WorldInfo.Game.BaseMutator==None) WorldInfo.Game.BaseMutator = Self; @@ -33,6 +35,8 @@ function PostBeginPlay() if (bDeleteMe) // This was a duplicate instance of the mutator. return; + ConfigChanged = False; + MapFile = string(WorldInfo.GetPackageName()); iCurrentHistory = class'xMapVoteHistory'.Static.GetMapHistory(MapFile,WorldInfo.Title); if (LastVotedGameInfo<0 || LastVotedGameInfo>=GameModes.Length) @@ -51,8 +55,18 @@ function PostBeginPlay() MidGameVotePct = 0.51; MapWinPct = 0.75; VoteTime = 35; - SaveConfig(); + ConfigChanged = True; } + + if (VoteNumForOrgy <= 0) + { + VoteNumForOrgy = 4; + bNoMapVoteOrgy = False; + ConfigChanged = True; + } + + if (ConfigChanged) + SaveConfig(); // Build maplist. z = 0; @@ -314,9 +328,10 @@ final function TallyVotes(optional bool bForce) // Finally pick a random winner from the best. c = Candidates[Rand(Candidates.Length)]; - if (NumVotees>=4 && ActiveVotes.Length==1) // If more then 4 voters and everyone voted same map?!!! Give the mapvote some orgy. + // If more then "VoteNumForOrgy" voters and everyone voted same map?!!! Give the mapvote some orgy. + if (!bNoMapVoteOrgy && NumVotees >= VoteNumForOrgy && ActiveVotes.Length==1) { - for (j=(ActiveVoters.Length-1); j>=0; --j) + for (j=(ActiveVoters.Length-1); j >= 0; --j) ActiveVoters[j].PlayerOwner.ClientPlaySound(AnnouncerCues[13]); } SwitchToLevel(ActiveVotes[c].GameIndex,ActiveVotes[c].MapIndex,false); @@ -409,7 +424,11 @@ function Timer() if (bMapvoteHasEnded) { - if (WorldInfo.NextSwitchCountdown<=0.f) // Mapswitch failed, force to random other map. + // NOTE: + // "WorldInfo.NetMode != NM_Standalone" prevents cyclic unsuccessful map change in single player mode. + // I have not tested how this code will behave if it really fails to change the map. + // Most likely there should be another solution here, but for now it will do. + if (WorldInfo.NetMode != NM_Standalone && WorldInfo.NextSwitchCountdown<=0.f) // Mapswitch failed, force to random other map. { ActiveVotes.Length = 0; bMapvoteHasEnded = false;