Redo Limit/CurrentMission check

Minimum for min/max check to avoid loop
This commit is contained in:
ChocoTaco 2020-01-12 00:36:05 -05:00
parent c82143731f
commit a182ab0723

View file

@ -37,14 +37,14 @@ function MapRepetitionChecker( %game )
return; return;
if(!$Host::TournamentMode && $Host::EnableMapRepetitionChecker) if(!$Host::TournamentMode && $Host::EnableMapRepetitionChecker)
{ {
//Do work //Do work
for(%x = 1; %x <= $MRC::PastMapsDepth; %x++) for(%x = 1; %x <= $MRC::PastMapsDepth; %x++)
{ {
if( $MRC::PrevMap[%x] !$= "" && $MRC::PrevMap[%x] $= $EvoCachedNextMission ) if( $MRC::PrevMap[%x] !$= "" && $MRC::PrevMap[%x] $= $EvoCachedNextMission || $CurrentMission $= $EvoCachedNextMission )
MapRepetitionCheckerFindRandom(); MapRepetitionCheckerFindRandom();
} }
//Set vars //Set vars
for(%x = $MRC::PastMapsDepth; %x >= 1; %x = %x - 1) for(%x = $MRC::PastMapsDepth; %x >= 1; %x = %x - 1)
{ {
@ -69,14 +69,15 @@ function MapRepetitionChecker( %game )
} }
} }
function MapRepetitionCheckerFindRandom() function MapRepetitionCheckerFindRandom(%redone)
{ {
//Make sure GetRandomMaps.cs is present //Make sure GetRandomMaps.cs is present
if(!$GetRandomMapsLoaded) if(!$GetRandomMapsLoaded)
return; return;
//Backup //Backup
$SetNextMissionRestore = $EvoCachedNextMission; if(%redone $="")
$SetNextMissionRestore = $EvoCachedNextMission;
//Do work //Do work
//getRandomMap() is in GetRandomMaps.cs //getRandomMap() is in GetRandomMaps.cs
@ -89,15 +90,19 @@ function MapRepetitionCheckerFindRandom()
if($MRC::PrevMap[%x] !$= "" && $MRC::PrevMap[%x] $= $EvoCachedNextMission) if($MRC::PrevMap[%x] !$= "" && $MRC::PrevMap[%x] $= $EvoCachedNextMission)
%redo = 1; %redo = 1;
} }
//Make sure its within maplimits //Make sure its within maplimits
%newmaplimits = $Host::MapPlayerLimits[$EvoCachedNextMission, $CurrentMissionType]; %newmaplimits = $Host::MapPlayerLimits[$EvoCachedNextMission, $CurrentMissionType];
%min = getWord(%newmaplimits,0); %min = getWord(%newmaplimits,0);
%max = getWord(%newmaplimits,1); %max = getWord(%newmaplimits,1);
if(%min > $AllPlayerCount || $AllPlayerCount > %max) if((%min > $AllPlayerCount || $AllPlayerCount > %max) && $AllPlayerCount > 2 )
%redo = 1; %redo = 1;
if( %redo ) if( %redo && %redone < 3 )
MapRepetitionCheckerFindRandom(); {
%redone++;
MapRepetitionCheckerFindRandom(%redone);
}
else else
{ {
error(formatTimeString("HH:nn:ss") SPC "Map Repetition Corrected from" SPC $SetNextMissionRestore SPC "to" SPC $EvoCachedNextMission @ "." ); error(formatTimeString("HH:nn:ss") SPC "Map Repetition Corrected from" SPC $SetNextMissionRestore SPC "to" SPC $EvoCachedNextMission @ "." );